Spring JMS API, JBoss MQ, BlazeDS & Flex

This time one more assignment to integrate Spring APIs with Jboss MQ. After reading through Spring documentation, I found its pretty easy to integrate any Messaging Provider solution into Spring application.

Configuring JMS Topic in JBoss

To create new JMS Topic destination you should configure new topic destination in [deploy_directory]/deploy/jms/jbossmq-destinations-service.xml. Following code snippet creates new Topic Destination.

Well in actual production system you should not configure guest role access with Read/write permission. Add above XML code snippet below <server> tag and save it. Start JBoss console and you should notice that JBoss will create new topic and bind it to JNDI with name as “topic/MyTopic” (Note this is generic JMS client configuration and doesn’t use any properitory JMS provider APIs. You will have to change the properties of jndiTemplate based on your Messaging Service Provider.)

Using Spring API

Now lets create client code to send messages. I assume that you are using Spring – BlazeDs integration project and aware of how to configure Spring configuration file with BlazeDS. The following code snippet must be defined in Spring configuration file. Make sure you have also imported Spring-Flex namespace.




Now you can expose jmsDestination using flex:jms-message-destination tag. (Available with Spring-BlazeDS integration jar.)

Creating Flex Client

We are done with the server side configuration and now its time to define Flex Client to subscribe to JMS topic. Flex comes with a handy tag as MX:Consumer and MX:Producer. MX:Consumer is useful to subscribe to JMS topics and queues, while MX:Producer by the name itself it is quite clear that this tag is used to publish messages to JMS. Declare following tag to subscribe to JMS topic

Note that in above example the value of destination attribute is exactly same as the value of id attribute defined for jms-message-destination tag. This still won’t start subscription to JMS topic and in order to start subscription you must explicitly subscribe to JMS topic by calling subscribe method  on MX:Consumer instance. Let assume that following function is invoked on “CreationComplete” event of application.

private function subscribeTopic():void

This will start subscription to JMS topic destination and keep on polling to message server for any new message. OK! but how you will receive message notification, notice there are two event handler defined with MX:Consumer tag declaration. And here is the code snippet of “message” event handler.

private function consumerMessageHandler(event:MessageEvent):void

var msg:AsyncMessage = new AsyncMessage(event.message);;

This function just prints all the contents of the Message. If you are accessing Object style JMS message, the properties of such message can be accessed using “.” notation.


Package all the generated SWFs and copy all the required files (JAR, XML configuration files etc) to a WAR file and deploy it on JBoss server. Hit your application URL and you should be able to receive any messages sent to JMS topic.

Known Issue

At the time of deployment, you might come across following exception being thrown by JBoss

: Failed to convert property value of type [] to required type [javax.jms.ConnectionFactory] for property ‘connectionFactory’

Make sure that the deployed WAR file doesn’t contain and JMS-API library file. The above error is occurring due to ClassLoader issue but the error message is misleading.

By Carbon Rider

Hi this is Yogesh, welcome to my world. Being passionate about learning new technologies and building frameworks, I end up spending most of my time in front of computer. But over last few months, I realised apart from being good coder and designer (Yes I am) I have something hidden in me. And thats called ART.

Leave a Reply