Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot with tibco jms listener

I am trying to listen Tibco ems queue (wants annotation based configuration) from SpringBoot. I don't see any example which described how to configure and listen Tibco ems queue from SpringBoot.

Any lead or example on this ?

like image 446
Sanjay Chandak Avatar asked Sep 15 '16 15:09

Sanjay Chandak


People also ask

What is JMS listener in spring boot?

The JmsListener annotation defines the name of the Destination that this method should listen to and the reference to the JmsListenerContainerFactory to use to create the underlying message listener container.

How do I start and stop JMS listener in Spring?

You can access the JMS listener containers from the registry (all or by name) and call stop() on the one(s) you want; the container will stop after any in-process messages complete their processing.

How does JMS listener work?

The JMS Listener adapter operates in an asynchronous mode. It establishes an asynchronous listener on the queue or topic destination specified by the JNDI name of Destination field. When a qualified message arrives at the destination, the adapter immediately processes the message.


1 Answers

Create a connection factory in the spring boot application class

@Bean
public ConnectionFactory connectionFactory(){

    TibjmsConnectionFactory connectionFactory = new TibjmsConnectionFactory(JMS_URL); 
    connectionFactory.setUserName(USERNAME);
    connectionFactory.setUserPassword(PASSWORD);

    return connectionFactory;
}

For sending message , use the send() of JmsMessagingTemplate .

The listener class should have an annotated method which has to be invoked for processing the message received from queue.

@JmsListener(destination = "queue_name")
public void receiveMessage(Message<T> message) {
   //Any processing to be done here
}
like image 196
Ratish Avatar answered Oct 27 '22 11:10

Ratish