Archive for the ‘spring’ Tag

Apache Camel + JBoss 5 + Spring

This is a followup to my previous post about how to get Apache Camel 1.6.0 to work using JBoss 5.  In this post, I provide some code to use configure Camel using Spring.  As with vanilla Camel, you cannot do this with JBoss 5 due to the fact that Camel’s ResolverUtil does not understand JBoss’s “virtual file system”.

Please note Claus Ibsen’s comment in my original post that he plans to allow the ResolverUtil to be configurable in Apache Camel 2.0.  In the meantime, you can refer to code I have provided at GitHub, which is based on camel-osgi.

As before, a pom.xml file is provided to build the jar.  Place the jar file in your JBoss 5 installation’s server/[config]/lib directory.

In your spring xml, be sure to use the new namespace that I have defined for Camel + JBoss 5 when you define your camelContext.  For example:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jboss="http://example.org/camel/schema/jboss"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://example.org/camel/schema/jboss http://example.org/camel/schema/jboss/camel-jboss.xsd
       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

  <jboss:camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
    <route>
      <from uri="imaps://imap.gmail.com?username=[yourusername]&amp;password=[yourpassword]&amp;
          deleteProcessedMessages=false&amp;consumer.delay=120000"/>
      <to uri="log:example.camel?level=DEBUG"/>
    </route>
  </jboss:camelContext>
</beans>