Tuesday, 1 September 2009

A HornetQ Simple Example using Maven

Since HornetQ can be run embedded and can be run with no little or no thirdparty dependencies, its easy to create a simple project that runs an embedded server or simple client. The example code can be downloaded from here and can be built and run as follows:
To build both the embedded server and client run mvn package from the root directory.
To run the server run mvn exec:java from the embedded-server directory.
To run the client run mvn exec:java from the client directory.
Now lets look more closely at both examples in more detail.
embedded server
Lets start by looking at the dependencies in the pom.xml found under the embedded-server directory.
The dependencies needed are configured as follows:

You can configure the server via the hornetq-configuration.xml file and configure any JMS objects via the hornetq-jms.xml file. Of course you can do much more than this with your server but this is a good starting point. Consult the HornetQ documentation for more information of what other features are available.
client
The client example shows how you can easily create a HornetQ JMS client using minimal jars. The dependencies this time are much smaller than the server and contain client jars that HornetQ provides for lightweight client apps.

I there an update for this fine example available that uses HornetQ 2.1.1 ?Using the client against a 211 server (within JBoss EAP 5.1 CR) shows issues on the JBoss side, which look like the wire format may have changed

17:42:45,843 ERROR [RemotingConnectionImpl] Failed to decodejava.lang.IndexOutOfBoundsException at org.jboss.netty.buffer.AbstractChannelBuffer.readByte(AbstractChannelBuffer.java:236) at org.hornetq.core.buffers.impl.ChannelBufferWrapper.readNullableString(ChannelBufferWrapper.java:64) at org.hornetq.core.protocol.core.impl.wireformat.CreateSessionMessage.decodeRest(CreateSessionMessage.java:192)

I would like to say that you really made my day, it's wonderful when you just look around the weband find something like this, reminds me of that ''How to make a dinner for a romantic...'' by Elsa Thomas,you're a wonderful writer let me tell you!!! ñ_ñ