Spring Integration JMS Poller to Retain Session Between Polls

41 Views Asked by At

I have a Spring Integration JMS poller on an IBM MQ Series queue. When using IBM MQ Explorer (IBM's Eclipse based queue browser application) and looking at the status of the queue, I see my application's queue handle status appear/disappear with every poll cycle. Is this expected behavior? Is it possible to retain the queue session between polls?

Example code is;

IntegrationFlows.from(
  Jms.inboundAdapter(connectionFactory).destination(myQueue),
  e -> e.poller(Pollers.fixedDelay(Duration.ofMillis(1000)))
)
.log(INFO, "Read Queue " + myQueue, m -> m)
.channel(myDirectChannel)
.get();

Using spring-integration-jms 5.5.7 and com.ibm.mq.allclient 9.1.5.

1

There are 1 best solutions below

1
Doug Grove On

Actually, yes - this is the expected behavior. In the simplest scenarios, the whole JMS connection and session are created, then used, and dropped for each message. This is obviously very inefficient.

You can use a caching connection factory to externalize the management of the JMS connection and session to avoid this behavior.