JBoss HornetQ component for Apache Camel (English Version)

In a previous post i wrote about the Apache Camel project. Camel is an excellent solution for system integration. Recently JBoss launched their new product, the new generation of messaging system: HornetQ which i have posted about it. In this post i came to show a very simple component for the integration of Apache Camel with JBoss HornetQ.

This is the very first version of the component and i will improve incrementally. This version is still beta, has some limitations but you'll be able to work with the Camel URI using my component to access the queues and topics of HornetQ.

Download and Usage

You can download the source code from my Subversion repository: http://diegopacheco.svn.beanstalkapp.com/sandbox/trunk/community/hornetq-camel-component once you have downloaded you must install the component using the Apache Maven. Just type in the command line (in the root folder of the project) the following command:
$ mvn clean install

Then you're ready to use the component in your project. In the src/test/java  and src/test/resources folder you have an example of how to use the component with the Apache Camel. I will comment it with more details and the usage.

Once installed in the maven the component you must reference it in the POM or in the classpath of your application(for nom-maven users), in pom use the following dependence:


This component is an extension of the Camel JMS component, most things will work through the inherited object, the URI syntax is the same. The ID of the spring bean registered as a component in the spring context must be used in the camel URI that you use for your routing.

Spring Configuration and Customization

<br /> <bean id="hornetq" class="com.blogspot.diegopacheco.camel.hornetq.component.HornetQComponent" ><br />   <property name="useNettyDefaults" value="true" /><br /> </bean><br />

This is the simplest configuration snippet for the component, that assumes that you want use the netty as a  connector and are using the default port on localhost. You can change this setting to use another connector or even create your custom connector of Netty or whatever you want, it is also possible to pass the Client ID  through the customization, it would be something like the XML below:

<br /> <bean id="hornetq" class="com.blogspot.diegopacheco.camel.hornetq.component.HornetQComponent">  <br /> <property name="connectionFactory"><br /> <bean class="com.blogspot.diegopacheco.camel.hornetq.component.HornetQCamelConnectionFactory"><br /> <property name="transportConfiguration"><br /> <bean class="org.hornetq.api.core.TransportConfiguration" ><br /> <constructor-arg index="0"><value>org.hornetq.integration.transports.netty.NettyConnectorFactory</value> </constructor-arg></bean><br /> </property><br /> </bean><br /> </property>  <br /> </bean><br /> 

Using HornetQ through the Camel URI

Well, now is the moment :D Camel URI usage sample. Take a look at XML snippet below:

<br /> <camelcontext xmlns="http://camel.apache.org/schema/spring" ><br /> <route><br /> <from uri="file://src/test/resources/data?delete=true"/><br /> <to uri="hornetq:queue:topic_hornetq"/><br /> </route><br /> <route><br /> <from uri="hornetq:queue:topic_hornetq"/><br /> <to uri="bean:beanConsumer"/><br /> </route><br /> </camelContext><br />

As you can see I'm using the *hornetq* on the URI, this is the ID of the Spring bean that refers to HornetQComponent. You could use another value here, since this value is the same in which this bean in the spring XML file. It is still possible to use Annotationss for Camel producers and comsumers as the same URI style.

Known Limitations and Future Implementations

This is the first version, it is possible that there are bugs(if you find a bug, you can send email or comment on blog), I know some limitations and things that have not implemented yet, this session will talk a little more about things that i will be implementing in future versions. Limitation(first version): 

  •   Create queues and topics in a dynamic way when they do not exist in HornetQ
  •   Access the HornetQ informing User and password to increase security (now uses the 'guest')
  •   Pooling and JNDI Support/Integration
I hope you like it (remembering that it is beta), I'll post  updates, releases and bug fixes. Contributions are welcome.
Best Regards,
Diego Pacheco

Popular posts from this blog

Telemetry and Microservices part2

Installing and Running ntop 2 on Amazon Linux OS

Fun with Apache Kafka