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

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.

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.

Can't turn of auto create function in embedded ActiveMQ

I would like to use ActiveMQ in my Spring Boot application. During debugging I have found out following error:
org.apache.activemq.broker.BrokerService : Failed to start Apache ActiveMQ (localhost, null)javax.management.InstanceAlreadyExistsException: org.apache.activemq:type=Broker,brokerName=localhost`
Seems like broker is created upon creation of the first connection, according to ActiveMQ's documentation. Is is possible to turn off auto-creation by setting the create property on the VM Transport to false, e.g.:
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?create=false");
When I tried this solution I got following error:
DefaultJmsMessageListenerContainer : Could not refresh JMS Connection for destination 'test' - retrying using FixedBackOff{interval=5000, currentAttempts=364, maxAttempts=unlimited}. Cause: Could not create Transport. Reason: java.io.IOException: Broker named 'localhost' does not exist.
Now I think the broker is not creating at all or this process is pending. Did anyone have a similar issue? If so how did you resolve it?
ActiveMQ's vm transport optionally creates a broker, or connects to a running broker.
Sounds like you are missing a step in your application boot-up plan. Either you need:
A component to startup the broker
Designate one of the connection factories to start the broker using the vm transport:
Designated broker startup connection factory:
vm://localhost?create=true
All other connection factories:
vm://localhost?create=false

Use same JMS ClientID for multiple destinations/topics

I'm working on an new application that subscribes to two topics on a JBoss 4 and processes incoming messages. Actually I'm using two DefaultMessageListenerContainer with durable subscriptions for the connection.
When I use the same ClientID for the durable Subscription the Container fails with the error:
2021-07-02T10:28:05.487+0200 [DefaultMessageListenerContainer-1] ERROR org.springframework.jms.listener.DefaultMessageListenerContainer - Could not refresh JMS Connection for destination 'TOPIC.providerDurableTopic' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: This client id 'ka03.9971.mueller.de' is already registered!
Are there any possibilities two use the same clientId for two different destinations. Is there maybe any other ListenerContainer that can handle multiple destinations with one container instance?
The reason we try to use the same clientId is because we try to replace an old application with it subscriptions. This old application connected to the topics within one JMS transaction and was able to use the same client id.
I guess one possible solution is to use the SingleConnectionFactory and set the clientId on it. So only one Connection will be used for both Topics
The JMS 1.1 specification explicitly prohibits multiple connections with the same Client ID. I see three potential solutions to your problem:
Each message listener can use a connection with a unique Client ID.
Both message listeners can use the same connection.
Upgrade to a JMS 2 broker (e.g. ActiveMQ Artemis). JMS 2 relaxed the requirements for durable subscriptions and Client ID is no longer strictly required.

Spring JMS with IBM MQ connection refresh or invalidation

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?

Configuration of WebMethods Client to connect to WebSphere JMS (not WebSphere MQ)

Currently I have setup two queues on WebSphere 7. One for sending and one for recieving messages.
I have configured a activation spec on the receiving queue and the messages are consumed fine by a Message Bean.
Also I have written a client that can run on a separate jvm which can send messages fine to the queue.
I am sure that the queues work.
Now I want to know how can I connect them with WebMetods. I know that WebMethods supports JBoss and WebLogic but no support for WebSphere.
I should be able to get this working just by providing:
a provider url - "iiop://172.17.13.65:2809"
a connection factory - "jms/ConnectionFactroy"
a queue name- "jms/inQueue"
and an initial context - "com.ibm.websphere.naming.WsnInitialContextFactory"
(at least this is what my client is using)
Is there anybody that has resolved this issue? And what are the steps they took?
Thank you in advance for your help.
We were able to get this implementation happen.
To solve this Web Methods had to import some jar files for Client JMS:
com.ibm.ws.ejb.thinclient_7.0.0 + com.ibm.ws.orb_7.0.0 + com.ibm.ws.sib.client.thin.jms_7.0.0
And use a bootstrap of this type PROVIDER_URL: "iiop://natasha:2810"
Alaso these details as previously mentioned:
a factory - "jms/ConnectionFactroy"
a queue name- "jms/inQueue" and
an initial context - "com.ibm.websphere.naming.WsnInitialContextFactory"

Resources