Spring JMS with IBM MQ connection refresh or invalidation - spring

Current situation:
Spring boot application using com.ibm.mq:mq-jms-spring-boot-starter is receiving messages from IBM MQ and is working fine. Our IBM MQ server closes inactive connections after an hour and this throws exceptions at the client application (IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2009' ('MQRC_CONNECTION_BROKEN')). The client recovers correctly by starting a new connection but we want to prevent these errors by invalidating connections so we frequently get a new connection.
To prevent these inactive connections we would like the client application to make a new connection every 10 minutes for example when listening for messages. How would we configure these connections timeouts?

Related

Camel JMS : connection refresh not working (IBM MQ)

I'm using the following endpoint :
jms:queue:MY_JMS_QUEUE?transacted=true&recoveryInterval=10000&testConnectionOnStartup=true
Everything works well but whenever the MQ connection is lost (due to IBM MQ server restart), the connection refresh does not work.
In my logs i have that :
ERROR [c.c.j.DefaultJmsMessageListenerContainer] []] Could not refresh JMS Connection for destination 'MY_JMS_QUEUE' - retrying using FixedBackOff{interval=10000, currentAttempts=0, maxAttempts=unlimited}. Cause: JMSWMQ0018: Failed to connect to queue manager 'xxx' with connection mode 'Client' ......('MQRC_Q_MGR_NOT_AVAILABLE')
And nothing else, i was expecting to have the same error messages multiples times with currentAttempts=1 then 2... until the MQ is back.
I checked the documentation but i don't see anything else. My configuration:
Camel version : 3.11.3
Java: 11.0.8
Spring boot : 2.5.2
As your connection mode is "Client" you can give the MQ automatic JMS client reconnection feature a try. You would need to configure the "ClientReconnectOptions" in the connection factory definition.

IBM WAS autoreconnect to IBM MQ

I have a Java EE aplication on IBM WAS 8.5.5.x which connects to IBM MQ 9.0 with Activation specs.
I'm interested in problem of autoreconnecting from WAS to MQ, if for some reason there was a connection loss (MQ server was shut down).
In IBM WAS admin console I have set Resources -> JMS -> Queue connection factories -> Factory -> Advanced properties -> Client reconnect options -> RECONNECT
I set Client reconnect timeout to 120 seconds.
That worked well (there was a reconnection) until queue manager was ended for a long period of time (about 9 hours).
Am I doing something wrong ? Is there a way to make QCF or Activation Spec auto reconnect if there was a connection loss. Is there a limit on number of reconnetion tries ?
This behavior can be controlled by updating the "Reconnection retry count" and "Reconnection retry interval" properties for "WebSphere MQ messaging provider" JMS provider in WAS console.
Path :Resources > JMS Providers > WebSphere MQ messaging provider (select scope) > Resource adapter properties (under Additional properties) .
Reconnection retry count : The maximum number of attempts made by a WebSphere MQ messaging provider activation specification to reconnect to a WebSphere MQ queue manager if a connection fails.
Reconnection retry interval : The time, in milliseconds, that a WebSphere MQ messaging provider activation specification waits before making another attempt to reconnect to a WebSphere MQ queue manager.
Refer : https://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/umj_pjmswmq_raprops.html for more details.

Stale connection in IBM MQ when connecting with WAS and Spring-JMS

We are using Websphere Applicaion Server with Spring JMS, Around 25 applications connect to a IBM MQ. Off-late we are seeing lots of stale connection on the MQ channel to which all these applications connect.
By stale connections I mean the connection are not being used for many days and the application keeps creating new connections. We are not able to identify which application creates these connections that are not being used but they all use the same framework code
WAS version = 8.5.5
Spring = 4.1.2
The Spring jms:listener-container has the following configuration
connection-factory = org.springframework.jms.connection.DelegatingConnectionFactory
acknowledge=auto
concurrency=2-10
Any pointers on any configurations that can be done on QueueConnectionFactory (JMS Resource) on WAS or on the spring side would be helpful.
I know I have not given much information, but the problem is that there are no errors / exceptions, the application creates these connections to the MQ channel and all connections gets cleared when the server is restarted
Adding one more question
We use org.springframework.jms.connection.DelegatingConnectionFactory , for replying back, Does it make sense for us to close the session once we have send back the message?
Thanks in Advance
Charlie

JMS Session Pooling with Message Listener

Relating to this question (JMS Connection Pooling in Message Listener), i'm currently trying to build a session pool upon a pool of connections that i'd created earlier.
I had managed to create a pool of JMS Connections and when i run it with my Producers and Consumers, they work fine. The Consumers is registered with a Message Listener to retrieve messages from the MQ.
However when i implemented the session pool, the message listener just stop working. The producers can send message out without problem, but the message listener never fired off.
The following code is the create code in the JmsSessionObjectFactory:
Connection connection = Application.getInstance().getConnectionPool().borrowObject();
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
Application.getInstance().getConnectionPool().returnObject(connection);
Is that the correct way to implement the factory creation for a session? Or my concept of session pooling with the connection pool is wrong?
Appreciate any advice. Thank you.

WebSphere MQ integration with WebLogic - issue sending messages to foreign queue

I'm testing a WebLogic MDB (running on my local Windows dev environment - Eclipse/WebLogic 10.3.2) with WebSphere MQ 6.0.1.0 (running on a Linux server). The WebSphere MQ components have been previously configured and I have the correct .bindings file.
I have followed the instructions described here.
I have no problem consuming messages that are placed on the MQ queue. However, when I attempt to configure the MDB to put messages back to the MQ queue I get the following warning upon server start-up:
<Warning> <JMSPool> <BEA-169808> <There was an error while making the initial
connection to the JMS resource named jms/WLSenderQCF from the EJB "TestMDB"
inside application "EJB Test 2EAR". The server will attempt the connection
again later. The error was javax.jms.JMSException: MQJMS1068: failed to obtain
XAResource>
If I place a message on the queue, my MDB consumes the messages, but these exceptions are thrown when the MDB attempts to put the message to the MQ Queue:
javax.jms.JMSException: MQJMS1068: failed to obtain XAResource...
javax.transaction.xa.XAException: client connection not XA enabled...
java.lang.NullPointerException
Anyone run into this and knows what the problem is?
Thanks for any help.
One issue seems to be the version of MQ you're using. It is ancient. IBM took MQ 6 out of support quite a while ago (Sept '12! http://www-01.ibm.com/support/docview.wss?uid=swg21584325).
Things got a lot easier when IBM decided to include the extended transactional client in the product for free: http://www-01.ibm.com/support/docview.wss?uid=swg21584325
So one option might be to upgrade to a version which includes this out of the box:
7.0.1.12+
7.1.0.5+
7.5
8.0
Otherwise... look into the v6 documentation on how to enable the 'extended transactional client' for JMS assuming you paid for it.

Resources