Send XML File JMS Queue

Send XML File JMS Queue

Many techniques are available to send XML file using JMS queue as it provides asynchronous communication channel between publisher and subscriber where both don’t know each other still getting required information. One common thing they need to follow is to registered with Queue or Topic to send and receive the messages. Sending text message is simple but sending file over the network is resource intensive. Imagine if you want to send large file over the network then you will have to serialized the data before sending it and serialized object will be loaded into memory before sending it.

To make thing simple without loading large file object into memory just create common location to upload file where both publisher and subscriber have access and send URL link through message so that subscriber could download and process file accordingly. If you are thinking what will happen to the file after subscriber processed it. Well, it’s up to you and your requirement if you want keep file for some time or whatever your purge policy is, otherwise once file process by subscriber successfully it can be deleted immediately or keep it as backup on other location for some time. In this demo I will show you how to crate command location and send file URL through message to process it.

Tools used:

  • JBoss application server jboss-6.1.0.Final community version (You can use any version of JBoss application server which you could download from here). If you are using version other than jboss-6.1.0.Final community version only JMS configuration will be different and use this tutorial to configure Queue and topic.
  • Eclipse Kepler (You could use any version of eclipse above 4.2)


  • Configure JMS Queue destination on jboss server : Go to jboss-6.1.0.Final\server\default\deploy\hornetq\hornetq-jms.xml and add below Queue

  • Now create maven project name JMSSendXMLFile with two class publisher and subscriber where one will publish message on queue and other will consume it (Please note: It’s publisher responsibility to create XML file send its path location through message to the subscriber so that he can consume it).

Send XML File JMS Queue

  • Create publisher class:

  • Create queue subscriber class:

  • Configure JBoss application server in eclipse using this tutorial
  • To include include all JBoss related jars to to class path: right click project –> properties –> Java build path –> on library tab click add library… –> Server runtime –> if you configured Jboss in eclipse you will see JBoss Runtime server choose it –> click finish.
  • Start JBoss server: Go to %JBOSS_HOME%/bin –> Double click run.bat to start the server. Once server is started it will pick up configured topic automatically.
  • Both class has main method start them separately as java application. Give file path name on publisher console and hit enter:

Send XML File JMS Queue

  • You will see once publisher publish file path message on queue, subscriber will pick up message and process file and print output on console:

Send XML File JMS Queue

download  Download Project:  JMSSendXMLFile

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *