Posted: Fri Apr 23, 2021 10:08 am Post subject: How to enable client acknowledge mode in JMS springboot app.
Newbie
Joined: 23 Apr 2021 Posts: 1
Hi Team,
We are using IBM MQ 9.1.0.2 and developed Springboot 2.0 JMS application to consume message from MQ. Based on our requirement we need to enable client_acknowledge and manually acknowledge the message.
We tried below JMS configuration but message.acknowledge() is not working for us.
Code:
@Bean
public MQQueueConnectionFactory mqQueueConnectionFactory() {
MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory();
mqQueueConnectionFactory.setHostName(host);
try {
mqQueueConnectionFactory.setTransportType(CommonConstants.WMQ_CM_CLIENT);
mqQueueConnectionFactory.setCCSID(1208);
mqQueueConnectionFactory.setChannel(channel);
mqQueueConnectionFactory.setPort(port);
mqQueueConnectionFactory.setQueueManager(queueManager);
@Bean
@Primary
public CachingConnectionFactory cachingConnectionFactory(
UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter) {
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
cachingConnectionFactory.setTargetConnectionFactory(userCredentialsConnectionFactoryAdapter);
cachingConnectionFactory.setSessionCacheSize(500);
cachingConnectionFactory.setReconnectOnException(true);
return cachingConnectionFactory;
}
@Bean
public PlatformTransactionManager jmsTransactionManager(CachingConnectionFactory cachingConnectionFactory) {
JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
jmsTransactionManager.setConnectionFactory(cachingConnectionFactory);
return jmsTransactionManager;
}
@Bean
public JmsOperations jmsOperations(CachingConnectionFactory cachingConnectionFactory) {
JmsTemplate jmsTemplate = new JmsTemplate(cachingConnectionFactory);
jmsTemplate.setReceiveTimeout(receiveTimeout);
jmsTemplate.setSessionAcknowledgeMode(AcknowledgeMode.CLIENT.getMode());
return jmsTemplate;
}
Can you please help us and let us know is there anything which we are missing in our end.
And is there any configuration changes need to be done on IBM MQ Queue Manager to enable client acknowledge?
It will be good if you can share some POC application with client acknowledgment enabled using JMS Listener.
Note:-
1.We are using Springboot 2.0 and JMS Listener to consume the message.
2.Consumed message are getting pushed back to queue if any exception is thrown from the @JMSListener annotated(OnMessage) method.
I don't understand you. Why are you even looking at client acknowledge when you could just as well be using a transaction? _________________ MQ & Broker admin
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum