Turn on more accessible mode
Turn off more accessible mode
Skip Ribbon Commands
Skip to main content
Turn off Animations
Turn on Animations
GET IN TOUCH

Skip Navigation LinksAddBlog
 

  • Home
  • Blogs
  • Connect JMS queue in IIB using Java

Step 1:

In order to connect the JMS queue we need to declare the host, Port of the jms queue manager and jms queue name

String host = "host Name";

int port = Port number;

String qName = "jms queue name"; 

Set the host name, Port number and jms queue name in host, port and qName respectively 

 

Step 2:

Create and declare the queue connectionFactory and queue session and queue

QueueConnectionFactory qConnFactory = null;

QueueConnection qConn = null;

QueueSession qSession = null;

Queue q = null;

 

Step 3:

Declare and create the queue receiver channel

STCQueueReceiver qRcvr = null;

Start the connection by using connection factory

qConnFactory = new STCQueueConnectionFactory(host, port);

qConn = qConnFactory.createQueueConnection();

qConn.start();

 

Step 4:

Create the queue session and receive/get the message from jms queue

qSession = qConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);

q = qSession.createQueue(qName);

 

Receive the message/data from the jms queue

 

qRcvr = (STCQueueReceiver) qSesh.createReceiver(q);

Message msg = (Message) qRcvr.receiveNoWait();

 

 

After get /received the data/message from the jms queue commit the queue session

 

if (qSession.getTransacted()) 

{

qSession.commit();

}

 

Step 5:

Close the receiver, session and connection in sequentially

qRcvr.close();

qSession.close();

 

Before closing the queue connection we need to stop the connection

qConn.stop();

qConn.close();

 

Comments

Follow Us

We ARE

Microsoft-Gold-partner-AVASOFT
CIO-Review-Award-AVASOFT

Reach Us