My experience with integrating HornetQ 2.1.1 and JBoss AS 4 (4.0.5-GA and 4.2.3-GA)
kentxu2007 Aug 6, 2010 7:36 PMI have been playing with HornetQ integration recently for connecting a legacy system in EJB2 running on JBoss 4.0.5-GA with other systems.
HornetQ is impressive and the team's support on the forum and doc is very helpful and better than many other projects I have seen. That's partially why I worte this post to give back a little.
The HornetQ documentation is great for JBoss 5 and examples are very useful too. Everything works out of the box.
When it comes to AS4 and EJB2, the information is murky and inaccurate in some cases. It is understandable since AS4 is old and not many new projects are using it. It took me a while to get MDB working. Since the wiki doc for "AS4 integration" is currently broken. I am going to post this hoping to help others in similar situation.
1. fresh intall jboss 4.2.3-GA. (if you are using jboss 4.0.5-GA, you need to download the latest log4j.jar and replace the log4j-boot.jar in the lib directory. The old log4j does not have "trace" related methods and hornetq fails)
2. run "build" from HornetQ 2.1.1 Final (config\jboss-as-4). I found "build.bat as4" (as in documentation) not working, just run it without the parameter.
3. comment out the two "TransactionManagerLocatorMethod" properties in deploy/jms-ra.rar/META-INF/ra.xml. Most references point you to hornetq-ra.rar, it is not correct in my case.
4. add a new queue to deploy/hornetq.sar/hornetq-ds.xml
<queue name="sbLibTopic">
<entry name="/queue/sbLibTopic"/>
</queue>
5. You can now verify sending and receiving message to this queue using simple standalone java client
e.g. go into hornetq-lab directory and run "ant sendreceivemsg"
6. edit standardjboss.xml, uncomment JMS message inflow from jmsra.rar section and comment out the default "message-drive-bean" invoker proxy binding. Restart jboss. I didn't see this step mentioned anywhere but it is crucial to get EJB working.
7. test MDB. deploy the sample EJB 2 MDB to the deploy directory. Notice the reference to "jms-ra.rar" not hornetq-ra.rar. I only find a "jms-ra.rar" in my deploy director
go into hornetq-lab directory and run "ant sendmsg"
you should see the MDB consume the message and output something like " test: Shredder onMessage: HornetQMessage..."
Source code attached, enjoy.
-
sample_code.zip 1.4 MB