Monday, June 7, 2010

Using Apache Camel from Clojure

I've been looking at Apache Camel for a project at work, and had a bit of trouble getting it working from Clojure, so I wrote this up in case anyone has the same issues.

The first example in Camel in Action watches a directory for new files, and copies them to an output directory. Here are the steps to get that running in Clojure, using leiningen.

  • Create your input and output directories
  • Create a new leiningen project
  • Add the following to the project.clj




  • run lein deps
  • Add the following to your src/org/whitlark/fc.clj (or whatever your last name is ;-)




Part of what screwed me up was the fact that you need to include spring in the project in order to get camel to work properly.

You can also use a macro to make the code even cleaner, like this:



Which I think compares nicely to the original Java:



I'm sure there are more improvements possible, but this got me started.

2 comments:

JesseHanson said...

good

dzyivsas0y said...

My college students chose an object and decided means to|tips on how to} divide it into different fractions. First of all, they needed to understand what a fraction is, then they needed to choose an object, measure it and select the places to chop to get four equal quarters. In small groups, my college students designed the most effective safety for best mens baseball cap the frequent egg-drop.