简体   繁体   中英

Spring integration with IBM MQ

I have read about the EJB MDB where its providing consuming the message from queue asynchronous and thread safe.

i was searching IBM MQ dependency for spring and i found "mq-jms-spring-boot-starter" but i am not getting any example that showing the consuming asynchronous data from queue/topic.

Does any body use this dependency to resolve asynchronous and thread safe issue in spring?

if not using this dependency then what are other option available in spring with IBM MQ to achieve the consuming asynchronous message reading?

i found the solution. we have to use IBM MQ dependency https://github.com/ibm-messaging/mq-jms-spring and then we can access queue asynchronous using following sample code.

public class Test {

@Bean
public JmsListenerContainerFactory<?> myFactory(
    ConnectionFactory connectionFactory,
    DefaultJmsListenerContainerFactoryConfigurer configurer) {
  DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
  factory.setConcurrency("5");
  configurer.configure(factory, connectionFactory);
  return factory;
}

@JmsListener(destination = "DEV.QUEUE.1", containerFactory = "myFactory")
public void receiveMessage(String transaction) {
  System.out.println("Received <" + transaction + ">"+ "start time"+System.currentTimeMillis());

}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM