Win a copy of Head First Android this week in the Android forum!

Bryan Copeland

Greenhorn
+ Follow
since May 17, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bryan Copeland

You need to be sure to include activemq5.3.1-all.jar in your project buildpath, they all come from the ActiveMQ library...
There's a shortcut which I found after lots of sifting through online resources/specs and


Summary:

1. you just need to create your own jndi.properties like a regular .properties file (start a plaintext file in your IDE and rename .properties, or, just a basic text editor like vi or notepad)

2. set the JMS properties to the location of your actual JMS server, some optional config, and any Topic or Queue names you want to create

3. package the jndi.properties as a .jar and include it in your buildpath (simply add as a library in your IDE and it will automagically add to your buildpath)



My sample jndi.properties for ActiveMQ:





Check these out for more info:
ActiveMQ - http://activemq.apache.org/jndi-support.html
jBoss - http://docs.jboss.org/jbossmessaging/docs/usermanual-2.0.0.beta1/html/using-jms.html
I've managed to write both an AJAX and a JAVA JMS client (in this case for ActiveMQ's JMS broker). Each have been working to consume and produce JMS messages as separate projects, unfortunately though, trying to run them in the same project does not work (possibly because of my own misunderstanding of Tomcat's limitations as a J2EE container). What I'm trying to do is have the JAVA client act as an "always-on" listener for when the AJAX JMS client is not listening (i.e. browser is closed). When a browser client opens, the (constantly running) JAVA client can ignore the messages... but... when no browser client is initialized, the JAVA client should respond to the messages on behalf of the AJAX client.

I've tried using a ServletContextListener pattern, which I was hoping would launch the JAVA listener via its main method, whenever the Servlet gets initialized (i.e. it would auto-start when Tomcat gets restarted, or, anytime the Servlet gets redeployed) but it seems Tomcat is not thread-safe and this might be causing some problems. In any case, I can't seem to get the JAVA client to reliably start running and stay running for the lifetime of my AJAX client (webapp .war), and without including them in the same project and same J2EE container sharing the same ServletContext, I don't know how its possible to ensure they are running, starting and stopping at the same time.

If anyone knows a solution for running AJAX and JAVA JMS connectors together, please share...