JBoss JMS Topic standalone application example

JBoss JMS Topic standalone application example

JMS Topic: It’s distribution mechanism to publishing message that has multiple subscriber. Usually in topic there is no guarantee that message will be delivered in order in which it has sent also no guarantee that each message will be processed once. As it has multiple subscriber means topic does not know all the subscribers and destination will be unknown. Once condition is that when topic is publishing message then subscriber (Client) should be active otherwise you will have to make durable subscription and it’s not mandatory to acknowledge messages process by the subscriber/client. In this demo you will see how to create Topic standalone application and JBoss JMS service.

Note: We will be using jboss-6.1.0.Final version for this demo.

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

JBoss JMS Topic standalone application example

  • Create maven project as below:

JBoss JMS Topic standalone application example

 

  • pom.xml:

  • JBossJMSTopicExample.java:

  • Important: If you are running as standalone application you need below Jars in your class path which you will find in “jboss-6.1.0.Final\common\lib” folder:

JBoss JMS Queue standalone application

  • To keep process simple add all JBoss Jars in your class path. Right click project –> Properties –> Add Library

JBoss JMS Queue standalone application

JBoss JMS Queue standalone application

  • Now start the JBoss server. Go to jboss-6.1.0.Final\bin –> Double click run.bat to start the server. Once server is started run the queue. Right click JBossJMSQueue.java –> Run As –> Java Application you will see below output on console:

JBoss JMS Topic standalone application example

For more information please visit oracle tutorial here

Leave a Reply

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