JMS Session Pooling with Message Listener - session

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.

Related

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?

Spring JMS messaging with JmsListener - how it scales?

I'm trying to use Spring JMS messaging with #JmsListener in a scalable way, but I'm not seeing it happening. I have a ConnectionFactory bean that returns a factory that connects to an Oracle Advanced Queue through JMS and a database DataSource pool.
The problem starts as every #JmsListener receiver connects again to JMS (and hence to the database pool). My understand is that I can have many #JmsListener methods, one for each service, but in this way it's doing I'm very limited.
The shared connection is turned on, but since each #JmsListener creates a different DefaultMessageListenerContainer, each one have a database connection.
If I also want the services to handle messages concurrently and set container.setConcurrency("3-5"), then it opens 3 * numberOfListeners connections.
If I use container.setCacheLevel(DefaultMessageListenerContainer.CACHE_NONE) then from each second every listener container connects and disconnects from the JMS/database.
I want something that connects one time (or more, if there is concurrent jobs to process) to JMS/database, not to connect count-of-listener times nor to connect-disconnect at each second for every listener.
You can use a SingleConnectionFactory to wrap the vendor factory and all containers will use the same connection.

Spring JMS 4.3.2 + Jboss EAP 6.4.8 + Webmethods Jms Broker 8.2 + Durable shared topic subscription

I'm trying to subscribe to a topic using durable and shared enabled, so that multiple instance can be connected to a topic to increase the scalability.
However, only the first instance getting connected without any errors, the second instance message listener keeps throwing the below error messages. I checked with my Webmethods counterpart and he found that the client state was disabled and that's why second listener was not able to connect using the same subscription name.
Can someone throw light on this issue please.
18:14:15,050 WARN
[org.springframework.jms.listener.DefaultMessageListenerContainer]
(DefaultMessageListenerContainer-145) Setup of JMS message listener
invoker failed for destination 'topicName' - trying to recover. Cause:
[BRM.10.2209] JMS: Durable subscription
"connectionFactory##subscriptionName" is in use.
The message
JMS: Durable subscription "connectionFactory##subscriptionName" is in use.
typically hints at a misconfiguration of your Topic on Broker. Please check (with MWS) that the Topic really has "Shared State=true“:
Then make sure your Connection Factory has a „Connection Factory Client ID“ set:
And finally you should set the following JVM setting:
-Dcom.webmethods.jms.clientIDSharing=true

Topic subscriber connection in Tibco

I have a process that starts with a topic subscriber.
What happens with a topic subscriber in Tibco if the EMS server shuts down?
I guess it will reconnect. But how many times or for how long it will try to reconnect?
The behaviour depends on various settings, set either on the client or server.
If you for example use a Java client you can set the behaviour through the connection factory:
TibjmsConnectionFactory.setReconnAttemptCount(10);
TibjmsConnectionFactory.setReconnAttemptDelay(1000);
TibjmsConnectionFactory.setReconnAttemptTimeout(1000);
You also can configure this behaviors on the server by using JNDI connections. Those can be defined through the factories.conf file.
BusinessWorks 5 does not reconnect by default, but honors all JNDI propagated settings.
It will try to connect indefinitely.

ActiveMQ Session AUTO_ACKNOWLEDGE property impact

Can anyone please explain me what is the impact of Session.AUTO_ACKNOWLEDGE for ActiveMQ JMS configurations
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
I believe by default ActiveMQ is set to auto acknowledge messages. This just means that when a message arrives it will automatically acknowledge that the message arrived. It is the same thing as calling .acknowledge() from the JMS object.
One reason to turn auto-acknowledge off is if you built a server and lets say you are processing each JMS Message and are doing some sort of DB transaction. If the transaction fails you would want the JMS message to be re-sent so you can fix your error and process it again. So in this sense you would only acknowledge the JMS object only after processing.

Resources