JMS Learning

IBM BPM added some event capabilities they call DEF for Dynamic Event Framework. It looks like this functionality could replace Tracking Groups and Tracking Points in process assets. Essentially DEF provides a way to dump notifications and data out of the process to an external system.

IBM KC Article on DEF
https://www.ibm.com/support/knowledgecenter/en/SSFPJS_8.5.7/com.ibm.wbpm.admin.doc/topics/capturingevents.html

My current role has a potential business case to connect an IBM BPM application to a Solace message engine. IBM BPM would both drop messages to Solace and also be able to consume messages (or be called from Solace to send a message over).

When I started some research on Solace and connecting it to WebSphere Application Server I realized I didn’t have any practical experience with JMS so I set aside some time this week to hack through some JMS tutorials and see what I could learn. Here are my notes from this journey.

Sites that helped

Old School JMS Tutorial from IBM: https://www.ibm.com/developerworks/java/tutorials/j-jms/j-jms-updated.html

JMS in Liberty:
https://github.com/WASdev/sample.jms.server

JMS Overview:
https://www.javatpoint.com/jms-tutorial

So first I just needed to learn the lingo of JMS and all of those sites helped with that. Next thing was to get coding, so I had to download the latest version of Eclipse (64-bit) for Java EE Developers. Easy enough. I already have a 64-bit Java JDK so there wasn’t a need to download anything new from Oracle.

My plan to take the code samples from Mr. Farrell’s IBM JMS overview and put those into a new project that will run on Liberty using the queues and topics setup by lauracowen’s demo. I like to combine things to help understand how each of them work and to avoid the cookbook approach of just following directions without understanding what was happening.

I wanted to focus on Pub/Sub so I took Mr. Farrell’s code for TPublisher.java and TSubscriber.java into a new Eclipse project. I liked that his code prompted for TopicConnectionFactory and Topic names; laura’s sample had the values in the code. So I figured I could use laura’s server.xml for Liberty and just type in the values to Mr. Farrell’s app and all would be good.

Well it turns out I couldn’t really figure out how to connect Mr. Farrell’s code to the Liberty JMS stuff in server.xml. I mean I ran the code “On Server” but I don’t really know if it had all the necessary context. It was failing at the JNDI look-up.

So instead of that approach and went with all of lauracowen’s code. I didn’t use Git for Eclipse so I just created a new project called jms11-JMSSample, copied all of her Java files and packages into Eclipse, used her server.xml and booted up Liberty.

I kept getting another JNDI failure. Ugh. It was here:

TopicConnectionFactory cf1 = (TopicConnectionFactory) new InitialContext().lookup("java:comp/env/jmsTCF");  

Again I couldn’t figure out what was the matter. The JNDI values seemed fine in server.xml:

	<jmsTopicConnectionFactory jndiName="jmsTCF"
		connectionManagerRef="ConMgr3" clientID="clientId1">
		<properties.wasJms />
	</jmsTopicConnectionFactory>

So what was the matter?

This is another case of not doing Java development frequently enough…I didn’t copy web.xml over. web.xml had the Java resource references that connected the code to the JNDI values. What’s interesting is that if I replaced the lookup value in the code with just “jmsTCGF” it worked fine – yay! But it look me a bit more time to understand how web.xml fit into that flow and get it corrected. The web apps worked perfectly after that.

My next task was to find some sort of tool that would let me look at the JMS queues and topics in Liberty. The sample web app had a little bit of info but I wanted to change it up and start dropping messages, not consume them, but be able to look at them somewhere else.

I found this application: JMSToolBox

It looked the a good solution so I downloaded the zip. Unfortunately I couldn’t get this tool to talk to my Liberty server. I have the full WAS JARs that are required and the Liberty JAR as well but I’m getting hung up on the SSL stuff. I don’t need SSL (everything is just local) but either Liberty or JMSToolbox is somehow forcing someting over https instead of just http…I’ll keep trying to work on this or maybe try a different tool…or just try jConsole. I’ll post an update later.

But in the end I had a good refresher on Java development, Liberty and an overview of JMS. Now I get to keep hacking with the code and start writing my own messages and topics.

Then maybe I’ll move on to adding an Elasticsearch index as a source for the messages…?

Leave a comment