Wednesday, October 21, 2009

A jira notification system for irc using camel

Last week, I thought that it would be a nice idea to have JIRA notifications for our Apache projects on IRC (for projects that sometimes use an IRC channel). So I came up with a very simple solution using Camel deployed on top of Karaf.

The application itself consists in a single xml file to be copied in the deploy folder of your Karaf installation. This was one of my requirements for ease of maintenance. This is possible because of the nice hot deployment mechanism for spring xml applications in Karaf.

Now, if you log onto the #camel, #cxf, #servicemix or #activemq IRC channels, you'll see some messages that look like:

jirabot: Claus Ibsen - Created: (CAMEL-2090) camel-jms -
Option autoStartup does not work
(see )

Those are all generated by the following applications:

<beans xmlns=""


<camelContext xmlns="">
<from uri="imaps://;password=xxx&amp;consumer.delay=1000&amp;delete=false" />
<convertBodyTo type="java.lang.String"/>
<!-- Remove any cr/lf that would cause regexp to not work -->
<setHeader headerName="tmpsubject">
request.headers.subject.replaceAll("\r\n", " ").replaceAll("\r|\n", "")
<!-- Extract the user name from the from header -->
<setHeader headerName="tmpfrom">
request.headers.from.replaceAll(".*\"(.*)\".*", "$1").replace("(JIRA)", "")
<!-- Camel -->
<setHeader headerName="">
<setHeader headerName="issuelink">
" (see" +
request.headers.tmpsubject.replaceAll(".*jira.*(CAMEL-[0-9]+).*", "$1") +
" )"
<!-- other projects filtering using the exact same mechanism -->
<!-- Other non jira emails -->
request.headers.from + ": " + request.headers.tmpsubject
<setHeader headerName="">
request.headers.tmpfrom + "- " +
request.headers.tmpsubject.replace("[jira]", "") +
<to uri="" />


This has been a small and enjoyable exercise. Camel rocks!