IBM MQ JMS connection not established from eclipse spring boot - spring-boot

I have been getting the issue of JMS connection refreshed from a few days.
Previously I was able to connect to the MQ and the same spring boot java code was working fine.
Now, the war file I build and deploy in the IBM Websphere also works. But it doesnt connect from Eclipse IDE. New to IBM MQ. Please help.
Setup of JMS message listener invoker failed for destination 'testq_OUT' - trying to recover. Cause: JMSCC0008: This connection is closed.
2022-03-10 14:44:28,659 INFO org.springframework.jms.connection.SingleConnectionFactory [DefaultMessageListenerContainer-1] Established shared JMS Connection: com.ibm.mq.jms.MQQueueConnection#3d803c95
2022-03-10 14:44:28,659 INFO org.springframework.jms.listener.DefaultMessageListenerContainer [DefaultMessageListenerContainer-1] Successfully refreshed JMS Connection
2022-03-10 14:44:34,767 WARN org.springframework.jms.listener.DefaultMessageListenerContainer [DefaultMessageListenerContainer-2] Setup of JMS message listener invoker failed for destination 'testq_OUT' - trying to recover. Cause: com.ibm.mq.MQException.<init>(Ljava/lang/String;Ljava/lang/String;II)V
2022-03-10 14:44:34,768 INFO org.springframework.jms.listener.DefaultMessageListenerContainer [DefaultMessageListenerContainer-2] Successfully refreshed JMS Connection
2022-03-10 14:44:40,788 WARN org.springframework.jms.listener.DefaultMessageListenerContainer [DefaultMessageListenerContainer-3] Setup of JMS message listener invoker failed for destination 'testq_OUT' - trying to recover. Cause: com.ibm.mq.MQException.<init>(Ljava/lang/String;Ljava/lang/String;II)V
2022-03-10 14:44:40,788 INFO org.springframework.jms.listener.DefaultMessageListenerContainer [DefaultMessageListenerContainer-3] Successfully refreshed JMS Connection
Please check the stack trace here

I found that some jms jars are not picked up from maven repo by the ide. so tried adding them on the build path and this works!

Related

Refresh JMS Connection in Spring Project using ActiveMQ

I have a Spring project in which I am using Apache Camel and ActiveMQ as message broker. When I started my Java application which receives from the topic and when the broker is not started it gives an error (which is valid), but even after starting the broker JMS connection is not refreshed.
I tried the same case in the Spring Boot app and it automatically refreshed the JMS connection. Something needs to be handled manually in Spring but not sure of that thing.
This is the error from my Spring app:
org.apache.camel.component.jms.DefaultJmsMessageListenerContainer: Could not refresh JMS Connection for destination 'test.events.topic' - retrying using FixedBackOff{interval=5000, currentAttempts=1, maxAttempts=unlimited}. Cause: Could not connect to broker URL: tcp://activemq:61616. Reason: java.net.UnknownHostException: activemq
This is what the Spring Boot application reports:
Successfully refreshed JMS Connection
Below is the broker configuration:
broker:
host: localhost
port: 61616
protocol: tcp
endpoint: ${broker.protocol}://${broker.host}:${broker.port}
url: failover:(${broker.endpoint}?wireFormat.maxInactivityDurationInitalDelay=30000)?timeout=3000&jms.useCompression=true&startupMaxReconnectAttempts=0&jms.redeliveryPolicy.maximumRedeliveries=${maxConsumers}

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.

Spring 5 JMS clientID=myapp.Topic was already set into another connection

I am using Spring Boot 2.2.1 (w/ Spring 5) to kick off my server with Spring JmsTemplate (HornetQ) connections. Every ~10s an ERROR is logged,
2020-01-17 18:00:49,091 [DefaultMessageListenerContainer-1] ERROR listener.DefaultMessageListenerContainer - Could not refresh JMS Connection for destination 'a.Topic' - retrying using FixedBackOff{interval=5000, currentAttempts=2, maxAttempts=unlimited}. Cause: clientID=myapp.Topic was already set into another connection
Did I accidentally create another client using the same id and compete for the connection/topic? Or something else I am not aware of.
Did I accidentally create another client using the same id and compete for the connection/topic?
Yes. According to the error message you're receiving you did.

SimpleMessageListenerContainer failed to reconnect on ems broker failover

I have 2 jms listener applications one application uses DefaultMessageListenerContainerand other application uses SimpleMessageListenerContainer
The application with DefaultMessageListenerContainer was able to reconnect on EMS broker failover, here is the log
Setup of JMS message listener invoker failed for destination 'SOME.TOPIC.T' - trying to recover. Cause: Connection is closed
Could not refresh JMS Connection for destination 'SOME.TOPIC.T' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: Failed to connect to any server at: tcp://localhost:8285,tcp://localhost:8286
Could not refresh JMS Connection for destination 'SOME.TOPIC.T' - retrying using FixedBackOff{interval=5000, currentAttempts=1, maxAttempts=unlimited}. Cause: Failed to connect to any server at: tcp://localhost:8285,tcp://localhost:8286
The application with SimpleMessageListenerContainer was not able to reconnect on EMS broker failover, here is the log
[TIBCO EMS TCPLink Reader (Server-109365)] INFO org.springframework.jms.listener.SimpleMessageListenerContainer - Trying to recover from JMS Connection exception: javax.jms.JMSException: Connection has been terminated
[TIBCO EMS TCPLink Reader (Server-109366)] ERROR org.springframework.jms.listener.SimpleMessageListenerContainer - Encountered non-recoverable JMSException
javax.jms.JMSException: Connection has been terminated
at com.tibco.tibjms.Tibjmsx.buildException(Tibjmsx.java:659) ~[tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsConnection._invokeOnExceptionCallback(TibjmsConnection.java:2118) [tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsConnection._onDisconnected(TibjmsConnection.java:2487) [tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsConnection$ServerLinkEventHandler.onEventDisconnected(TibjmsConnection.java:367) [tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.work(TibjmsxLinkTcp.java:328) [tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.run(TibjmsxLinkTcp.java:259) [tibjms-8.3.0.jar!/:?]
Both are connected to same broker instance, how to make the SimpleMessageListenerContainer listener to reconnect on JMS Exceptions?
The simple container is ... er ... Simple.
It makes only one attempt to recover the connection.
The default container is more sophisticated and configured with a BackOff (default every 5 seconds for infinite attempts).
Use a default container if you need that sophistication, but it needs to be transactional to avoid the possibility of message loss - see the javadocs.

How to use Worklight JMS adapter to connect to WebSphere MQ

I have followed the steps given in this link to get the JMS adapter working, but couldn't get it working
http://www.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/devref/t_connecting_jms_adapters_to_websphere_mq.html
I am using Worklight Devlopment Server v6.2, and I am trying to connect to WebSphere MQ (both worklight & mq are on the same machine), would jms adapter work with this setup ? Are there any other configurations that needs to be done for this to work
below are the adapter entry combinations that I have tried
Combination 1:
<namingConnection url="file:/C:/K5/JNDI_DIR/"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"/>
<jmsConnection connectionFactory="TESTJMSCONNFAC" />
Error message: [ERROR ] FWLSE0005W: JMS connection exception received: null. Closing the connection.
Combination 2:
<namingConnection url="tcp://localhost:1414"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"/>
<jmsConnection connectionFactory="MQConnectionFactory" />
Error message: [ERROR ] FWLSE0005W: JMS connection exception received: tcp://localhost:1414. Closing the connection.
Configuration Info below:

Resources