Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Let's talk about datomic.
- Loading branch information
Showing
1 changed file
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
--- | ||
title: Using Immutant With Datomic | ||
author: The Immutant Team | ||
layout: news | ||
tags: [ datomic, messaging ] | ||
--- | ||
|
||
Immutant 2.x is just a set of libraries, usable from a standard | ||
Clojure application. The [Datomic] peer client is also a library, so | ||
in theory we can use Immutant and Datomic together in the same | ||
application. But in pratice, it's not that simple. | ||
|
||
The sticking point is [HornetQ] - Datomic uses HornetQ to connect | ||
peers to the transactor and depends on HornetQ 2.3.x, while Immutant | ||
depends on 2.4.x. We should be able to resolve this with the proper | ||
dependency exclusions - the API that Datomic uses in 2.3.x is | ||
available in 2.4.x, but there are two issues that prevent that from | ||
working with the current stable release of Immutant ([2.0.2]): | ||
|
||
1. Immutant 2.0.x uses the [JMS 2.0] API, which didn't appear in | ||
HornetQ until 2.4.0, so 2.4.x is required. | ||
2. The HornetQ transactor is running HornetQ 2.3.x, and a 2.4.x client | ||
can't connect to a 2.3.x server, so 2.3.x is required. | ||
|
||
Hence our pickle. | ||
|
||
But, all is not lost - with Immutant 2.0.x, you have two (non-awesome) | ||
options for using Datomic, and if you are willing to use recent | ||
Immutant [incremental builds][incremental] (and are willing to upgrade to | ||
Immutant 2.1.0 when it is released in a few weeks), you have a third, | ||
more palatable option. | ||
|
||
## Option 1 - No Immutant Messaging | ||
|
||
The first option for using Datomic with Immutant 2.0.x is to not use | ||
Immutant messaging. This requires either depending individually on the | ||
Immutant libraries you are using: | ||
|
||
<pre class="syntax clojure"> | ||
:dependencies [[com.datomic/datomic-pro "0.9.5206"] | ||
[org.immutant/web "2.0.2"] | ||
[org.immutant/scheduling "2.0.2"] | ||
...] | ||
</pre> | ||
|
||
or using the catch-all artifact, and excluding messaging: | ||
|
||
<pre class="syntax clojure"> | ||
:dependencies [[com.datomic/datomic-pro "0.9.5206"] | ||
[org.immutant/immutant "2.0.2" | ||
:exclusions [org.immutant/messaging]] | ||
...] | ||
</pre> | ||
|
||
But this means you can't use any of the Immutant [messaging features], | ||
which isn't great. | ||
|
||
## Option 2 - In WildFly Only | ||
|
||
Inside the [WildFly] application server, Immutant doesn't directly use | ||
any on the HornetQ APIs, and just uses the JMS API to communicate with | ||
the HornetQ provided by WildFly. That HornetQ is ClassLoader-isolated, | ||
which means your application can bring in its own version of HornetQ | ||
(in this case, 2.3.x via Datomic), which can be used without issue. | ||
|
||
But this means you have to do all of your development against an | ||
application running inside WildFly, which isn't a great development | ||
experience. With our ["dev" war], you can still have a REPL-driven | ||
process, but it is definitely more painful than out-of-container | ||
development. | ||
|
||
## Option 3 - Use Recent Incrementals/future Immutant 2.1.0 | ||
|
||
For Immutant 2.1.0, we're working on supporting | ||
[Red Hat JBoss Enterprise Application Platform] (which is a mouthful, | ||
so we'll just call it EAP for short). EAP is the commercialized | ||
version of the open source application server (WildFly), and the | ||
current version (6.4.0) is based off an older WildFly that uses | ||
HornetQ 2.3.x. We'll cover what EAP support really means in a future | ||
blog post - what matters today is that changes we've made in Immutant | ||
to support EAP allow you to use Immutant messaging with Datomic both | ||
in and out of WildFly (and soon EAP). | ||
|
||
The only issues with this option is you have to use a recent | ||
incremental build of Immutant until we release 2.1.0, and do a few | ||
dependency exclusions/inclusions to make Immutant messaging and | ||
Datomic play nicely. Luckily, we've figured that out for you! The bare | ||
minimum to get things working is: | ||
|
||
<pre class="syntax clojure"> | ||
:dependencies [[org.immutant/immutant "2.x.incremental.602"] | ||
;; Datomic transitively brings in HornetQ 2.3.17.Final, which | ||
;; overrides the HornetQ 2.4.5.Final from org.immutant/messaging | ||
[com.datomic/datomic-pro "0.9.5206"] | ||
;; org.immutant/messaging requires this, but Datomic doesn't | ||
;; bring it in, so we have to depend on it explicitly | ||
[org.hornetq/hornetq-jms-server "2.3.17.Final" | ||
:exclusions [org.jboss.jbossts.jts/jbossjts-jacorb]] | ||
</pre> | ||
|
||
Now that you have it working, you probably want to get rid of all of | ||
the warnings from Leiningen's pedantic report. Don't worry, we've | ||
figured that out for you as well: | ||
|
||
<pre class="syntax clojure"> | ||
:dependencies [[org.immutant/immutant "2.x.incremental.602" | ||
:exclusions [org.hornetq/hornetq-server | ||
org.hornetq/hornetq-jms-server | ||
org.hornetq/hornetq-journal | ||
org.hornetq/hornetq-commons]] | ||
[com.datomic/datomic-pro "0.9.5206" | ||
:exclusions [org.slf4j/slf4j-nop | ||
joda-time | ||
commons-codec]] | ||
[org.hornetq/hornetq-jms-server "2.3.17.Final" | ||
:exclusions [org.jboss.spec.javax.transaction/jboss-transaction-api_1.1_spec | ||
org.jboss.logging/jboss-logging | ||
org.jboss/jboss-transaction-spi | ||
org.jgroups/jgroups | ||
org.jboss.jbossts.jts/jbossjts-jacorb]]] | ||
</pre> | ||
|
||
Note again that this option currently requires you to run a recent | ||
[incremental build][incremental] (#602 or newer), which requires | ||
relying on our incremental repo: | ||
|
||
<pre class="syntax clojure"> | ||
:repositories [["Immutant incremental builds" "http://downloads.immutant.org/incremental/"]] | ||
</pre> | ||
|
||
## Get In Touch | ||
|
||
If you have any questions, issues, or other feedback about Datomic | ||
with Immutant, you can always find us on | ||
[#immutant on freenode](/community/) or | ||
[our mailing lists](/community/mailing_lists). | ||
|
||
[Datomic]: http://www.datomic.com/ | ||
[HornetQ]: http://hornetq.org | ||
[2.0.2]: /news/2015/06/22/announcing-2-0-2/ | ||
[incremental]: /builds/2x/ | ||
[messaging features]: http://immutant.org/documentation/current/apidoc/immutant.messaging.html | ||
[WildFly]: http://wildfly.org/ | ||
["dev" war]: https://github.com/immutant/lein-immutant/blob/master/docs/deployment.md | ||
[Red Hat JBoss Enterprise Application Platform]: https://www.redhat.com/en/technologies/jboss-middleware/application-platform |