erlang-clojure node template
Branch: master
Clone or download
Pull request Compare This branch is 14 commits ahead of Elzor:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cljnode
include
src
test
.gitignore
Makefile
README.md
rebar.config

README.md

erlang-clojure-node

Erlang-Clojure (JVM) Interop using JInterface.

Building

To get started, build the Clojure Uberjar for cljnode and compile the Erlang source files:

$ make compile

Running

Once everything has compile successfully, you can start an Erlang shell and then bring the app up:

$ make shell
application:load(clojurenode).
application:start(clojurenode).

Or, you can just use the dev make target:

$ make dev

Once the app has started, you will see output like the following (elided):

(erl_node@cahwsx01)1> src/clj_controller.erl:200:<0.44.0>:...
   starting clojure app with cmd "java -Dnode=\"clj_node@cahwsx01\" ...

src/clj_controller.erl:201:<0.44.0>: [{{2014,5,11},{22,37,1}}] ...

INFO: starting clojure app with cmd "java -Dnode=...

At this point, you are in the shell, and before too long you should also see a log message display showing the successful start of the Clojure node:

src/clj_controller.erl:131:<0.44.0>: [{{2014,5,11},{22,37,6}}] ...
INFO: connection to java node established, pid <6709.1.0>

Using

Now that you've got both ends of the connection up, you can take it for a spin with a ping command:

(erl_node@cahwsx01)1> erlang:send(
  {clj_mbox, clj_node@cahwsx01}, {ping, self()}).
{ping,<0.57.0>})

To see the response from the Clojure node, you'll need to flush the shell:

(erl_node@cahwsx01)2> flush().
Shell got {pong,<6709.1.0>}
ok

Hurray! A successful response from the Clojure node!