ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » How to enable client acknowledge mode in JMS springboot app.

Post new topic  Reply to topic
 How to enable client acknowledge mode in JMS springboot app. « View previous topic :: View next topic » 
Author Message
sourav.suman18
PostPosted: Fri Apr 23, 2021 10:08 am    Post subject: How to enable client acknowledge mode in JMS springboot app. Reply with quote

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);

   } catch (Exception e) {
      System.out.println(e.getLocalizedMessage());
      e.printStackTrace();
   }
   return mqQueueConnectionFactory;
}

@Bean
UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter(
      MQQueueConnectionFactory mqQueueConnectionFactory) {
   UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter = new UserCredentialsConnectionFactoryAdapter();
   userCredentialsConnectionFactoryAdapter.setUsername(username);
   userCredentialsConnectionFactoryAdapter.setPassword(password);
   userCredentialsConnectionFactoryAdapter.setTargetConnectionFactory(mqQueueConnectionFactory);
   return userCredentialsConnectionFactoryAdapter;
}

@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.

Thanks
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Fri Apr 23, 2021 3:30 pm    Post subject: Re: How to enable client acknowledge mode in JMS springboot Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3253
Location: London, ON Canada

Note: In the future, wrap your code with the [code ] [/code ] tags (no spaces).

sourav.suman18 wrote:
We are using IBM MQ 9.1.0.2 and developed Springboot 2.0 JMS application to consume message from MQ.

We tried below JMS configuration but message.acknowledge() is not working for us.

So, that's the MQ JAR versions that you are using in your client application? And not the queue manager version.

IBM has implemented most of the features of JMS v2.0 but you will have to check with IBM if that particular feature is implemented.

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Fri Apr 23, 2021 9:04 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

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
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » How to enable client acknowledge mode in JMS springboot app.
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.