immutant

http://immutant.org Note: dev discussion happens in #immutant on FreeNode IRC.
colin.yates 2015-09-21T11:06:51.000024Z

hi there - I am getting lost in the forest of wildfly documentation. At the moment my JDBC driver pulls environment variables using env rather than using JNDI resources. What’s the quickest and secondly the idiomatic way :simple_smile: to pass in deployment specific properties to an immutant WAR in wildfly?

colin.yates 2015-09-21T11:06:55.000025Z

and thanks!

colin.yates 2015-09-21T11:27:15.000026Z

so one answer is to pass in —properties=/my/path/to/app.properties when calling bin/standalone.sh (but it seems it must be fully qualified)

2015-09-21T13:15:13.000027Z

hi colin. we usually recommend the environ lib for app config, even when deployed to WF

2015-09-21T13:15:46.000028Z

but if you're dealing with a JDBC datasource configured in standalone.xml, that may be trickier

2015-09-21T13:16:05.000029Z

so what exactly are you configuring? :simple_smile:

2015-09-21T13:16:59.000030Z

and keep in mind that "quickest" and "idiomatic" are often at odds on wildfly :simple_smile:

colin.yates 2015-09-21T13:17:06.000031Z

yes, I am learning that :simple_smile:

colin.yates 2015-09-21T13:17:31.000032Z

So I typically build up a datasource compatible map pulling in the parameters using env

colin.yates 2015-09-21T13:17:37.000033Z

e.g. (goes to find one…)

colin.yates 2015-09-21T13:18:32.000034Z

(def prod-spec "The production database envionrment" {:subprotocol "jtds:sqlserver" :subname (str "//" (env/env :health-db-server) ":" 1433 "/" (env/env :health-db-name)) :user (env/env :health-db-user) :password (env/env :health-db-password)})

colin.yates 2015-09-21T13:18:55.000035Z

at the moment when I do ‘lein run’ I simply pass them in as system variables

colin.yates 2015-09-21T13:19:46.000036Z

putting those properties into a .properties file and launching bin/standalone.sh —properties=that-file.properties makes it work

colin.yates 2015-09-21T13:19:57.000037Z

but that feels hacky...

2015-09-21T13:23:35.000038Z

well, hacky is a state of mind. the "idiomatic" way would be more like this:

2015-09-21T13:23:39.000039Z

(def db-spec {:factory immutant.transactions.jdbc/factory :name "java:jboss/datasources/ExampleDS"})

2015-09-21T13:23:53.000040Z

but that pushes all the config into your standalone.xml

2015-09-21T13:23:56.000041Z

also hacky

colin.yates 2015-09-21T13:24:32.000042Z

ah OK. I don’t feel too bad then.

2015-09-21T13:32:53.000043Z

i will say, colin, that same process (passing --properties) should work for configuring both places (your app or standalone.xml) since you can refer to properties in standalone.xml

2015-09-21T13:33:08.000044Z

there are some tradeoffs there

2015-09-21T13:33:50.000045Z

downside is you have to maintain your own standalone.xml, which is kind of a pain when upgrading your wildfly version

2015-09-21T13:34:20.000046Z

upside is your datasource can then participate in a distributed transaction, but that may not be worth anything to you

colin.yates 2015-09-21T13:38:36.000047Z

good to know. For me it is about lightweight deployment so the properties file is probably the way to go

2015-09-21T13:41:16.000048Z

@colin.yates: i'm curious why you're deploying to wildfly then. is it only to facilitate deployment on windows (i saw your ML post)?

colin.yates 2015-09-21T13:54:17.000049Z

good question. That is certainly the main reason and I am just about to start including things like quartz, possibly caching further down the line and a few people whose opinion I respect are choosing wildfly over http-kit.

colin.yates 2015-09-21T13:54:51.000050Z

My reason for http-kit is for sente - whether I still use that or the immutant websockets support is TBD

colin.yates 2015-09-21T13:55:23.000051Z

at some point I got fed up with chasing libraries and a curated set wins. (don’t get me started on #C099W16KZ roll your own or #prelude :-)).

2015-09-21T13:55:41.000052Z

If you use http-kit, are you going to do so from the war file deployed to WildFly?

2015-09-21T13:56:04.000053Z

if so, you'll have to run http-kit on another port, which would be a bit weird

colin.yates 2015-09-21T13:56:04.000054Z

@tcrawley: no, I am going to undertow via wildfly

2015-09-21T13:56:13.000055Z

good call :)

colin.yates 2015-09-21T13:56:53.000056Z

my migration was: sente rocks -> http-kit -> windows then a whole bunch of yak health care maintenance, realisation there must be better things in life and Immutant

2015-09-21T13:58:57.000057Z

@colin.yates: funny you mention quartz since it's not provided by wildfly. it's the immutant.scheduling lib that pulls that in, so it works the same in or out of a container.

colin.yates 2015-09-21T13:59:32.000058Z

yes, exactly. At some point I realised that Immutant was where I was heading anyway so why do it myself? Wildfly is really a means to an end for me.

jaen 2015-09-21T14:01:04.000059Z

@colin.yates: doesn't new sente support immutant too though? At least if that's your reason for keeping http-kit.

colin.yates 2015-09-21T14:01:28.000060Z

it does but I have no preference for http-kit.

2015-09-21T14:01:44.000061Z

it might be worthwhile to research "deploying clojure jars as windows services" solutions before committing to wildfly, if windows is the only reason you're looking at it. or maybe just replicate its bin/standalone.bat script for your jar? (i know bupkis about windows services)

colin.yates 2015-09-21T14:02:03.000062Z

I seem to have given the impression of some allegiance towards http-kit - it is great and all, but it is a means to an end

colin.yates 2015-09-21T14:02:57.000063Z

I know slightly more than bupkis as well but enough to know it is painful. I also want (as close to a) single deployment approach and wildfly gives me that across the macs, linuxes and windows

jaen 2015-09-21T14:03:36.000064Z

What I've meant if the only reason you're using http-kit is sente, then since sente 1.4.0 there's no reason to anymore - you can use it with immutant no problem.

colin.yates 2015-09-21T14:03:48.000065Z

@jaen - yep, we are on the same page :simple_smile:

jaen 2015-09-21T14:04:30.000066Z

Ah, gotcha, I must have misunderstood you, I parsed it as "I'm keeping http-kit because sente doesn't support immutant" for some reasone. My bad then.

colin.yates 2015-09-21T14:04:39.000067Z

urk, I just realised my message was ambiguous: "my migration was: sente rocks -> http-kit -> windows then a whole bunch of yak health care maintenance, realisation there must be better things in life and Immutant” should have ended “better things in life and Immutant was the answer"

colin.yates 2015-09-21T14:04:56.000068Z

@jaen, I seem unable to type today - I almost certainly led you down the wrong path :simple_smile:

jaen 2015-09-21T14:05:23.000069Z

Hah, happens. Luckily no one was seriously injured ; d

colin.yates 2015-09-21T14:05:32.000070Z

you know those days when the best thing for the project is to stay in bed….