This tutorial takes you through some of the basic steps of integrating Delphi applications and JBoss AS 5 with the help of Habari Client for HornetQ.
To complete this tutorial, you need the software and resources listeds in the following list.
- JDK 6
- JBoss 5.1.0.GA for JDK 6
- HornetQ 2.1.0.Final
- Habari Client for HornetQ – ProducerTool and ConsumerTool
Download and install HornetQ 2.1.0.Final
Download the HornetQ 2.1.0.Final distribution zip archive from http://www.jboss.org/hornetq/downloads.html. After downloading the distribution, unzip it into your chosen directory. At this point it should be possible to run straight out of the box. The full installation documentation is here.
Creating AS 5 Profiles
HornetQ is not currently shipped by default with the JBoss 5 application server (it is scheduled to be shipped as default JMS provider in JBoss Application Server 6.0), so you will need to create new AS 5 profiles to run AS 5 with HornetQ.
To create AS 5 profiles:
- Set the environment property JBOSS_HOME to point to the directory where you installed JBoss AS 5
- run ./build.sh (or build.bat if you are on Windows) in HornetQ’s config/jboss-as directory
This will create 2 new profiles in $JBOSS_HOME/server:
- default-with-hornetq — it corresponds to AS 5 default profile with HornetQ as its JMS provider. In this profile, HornetQ is non-clustered
- all-with-hornetq — it corresponds to AS 5 all profile with HornetQ as its JMS provider. In this profile, HornetQ is clustered
Broker Configuration
Open the file $JBOSS_HOME/default-with-hornetq/deploy/hornetq.sar/hornetq-configuration.xml to enable the Stomp acceptor.
<acceptors>
...
<acceptor name="stomp">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="protocol" value="stomp"/>
<param key="port" value="61613"/>
</acceptor>
...
</acceptors>
Open the file $JBOSS_HOME/default-with-hornetq/deploy/hornetq.sar/hornetq-jms.xml to add an example JMS queue.
<configuration ...>
...
<queue name="ExampleQueue">
<entry name="/queue/ExampleQueue"/>
</queue>
...
</configuration>
Start JBoss
You can now start JBoss AS 5 using the default-with-hornetq profile:
- $JBOSS_HOME/bin/run.sh -c default-with-hornetq
or (on Windows)
- $JBOSS_HOME/bin/run.bat -c default-with-hornetq
With netstat /a you can verify if the Stomp acceptor is running on port 61613.
Running the Delphi Test
Now you are ready to produce and consume messages with Habari HornetQ Client.
- start ProducerTool application to send messages to the queue ExampleQueue
- start the ConsumerTool application to receive the messages