Azure service bus javax.jms.IllegalStateException: The MessageProducer was closed due to an unrecoverable error - amqp

I am using ASB for enqueue/dequeue messages between components. Component A consumes messages from queue A and produces messages from queue B. It consumes then produces when consume. Both queues are using same Azure service bus with different queue name (A and B).
My problem is that once the component becomes idle for more than like 10~15 minutes, and then tries to consumes/produces, it throws
javax.jms.IllegalStateException: The MessageProducer was closed due to an unrecoverable error.
and
Caused by: javax.jms.JMSException: The link 'G5S1:40611071:qpid-jms:sender:ID:bbc3fc62-4377-4aeb-bb80-117d74e780de:1:47:1:queueB' is force detached. Code: publisher(link578). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00. [condition = amqp:link:detach-forced]
After observing the stack trace and behavior, it is having problems when it tries to produce a message to queueB. For consumer and producer, I am using same name bean cachingConnectionFactory() in MessageGateway beans (not sure it matters).
My guess is that when it consumes, it restart connection with queueA, and when it tries to restart connection with queueB, something is wrong.
Anyone has any idea? If need more information, please let me know.

Did you try to disable the cache producers? something similar to :
CachingConnectionFactory connectionFactory = (CachingConnectionFactory) jmsTemplte.getConnectionFactory();
connectionFactory.setCacheProducers(false);

Related

How to handle Connection Error in Message Driven Beans?

I have a Message Driven Bean listening to MQ Receiver Queue for incoming Messages.
My MDB is implementing MessageListener and overriding OnMessage method, where I can handle any exception related to the received messages.
All the Connection & Queue parameters are in ejb-jar.xml and weblogic-ejb-jar.xml.
So in case of any Connection failure (e.g. MQ is down, I just get Exception in the console).
How should I catch and handle these connection failure related exceptions in MDB? As I have requirement to send Email notifications to Support group in case of such Connection Failures.
I just saw some info about javax.jms.ExceptionListener, but there is no way I could use it for my setup as I don't have direct access to my connectionfactory / connection objects in case of my MDB.

Is it possible to have a remote pooled JMS connection factory (WildFly 10)?

I have a remote java client which looks up a JMS connection factory on Wildfly 10, and everything works fine as expected. It is just a test program; a simple JMS chat system. When I start more than one instance of the chat client sometimes the following message appears:
WARN: AMQ212051: Invalid concurrent session usage. Sessions are not supposed to be used by more than one thread concurrently.
Followed by a trace.
Now I want to fix this warning, therefore I need a pooled connection factory. But the pooled connection factory isn't available remotely (and as I read it shouldn't be available remotely).
What can I do to fix this warning when I want to start multiple JMS chat clients locally?
I know that the error won't appear when I just different machines.
This is the working non-pooled remote code (but with warning)
final Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
try {
context = new InitialContext(properties);
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
jmsContext = connectionFactory.createContext("quickstartUser", "quickstartPwd1!");
} catch (NamingException e) {
e.printStackTrace();
}
The problem isn't caused by not using a pooled connection factory and won't be solved by using a pooled connection factory. The problem is the way your application is using the same JMS session concurrently between multiple threads (as the WARN message indicates). The stack-trace which is logged will show you which class & method is triggering the WARN message.
You need to ensure that your application does not use the same JMS session concurrently between multiple threads. You can do this by giving each thread its own JMS session or by setting up concurrency controls around the session so that only one thread at a time can access it.

How to safely resume cache operation on client side after Hazelcast restart?

Whenever I restart hazelcast server, without restarting client in spring boot. I'm getting following error :
03-01-2018 16:44:17.966 [http-nio-8080-exec-7] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet].log - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.hazelcast.client.HazelcastClientNotActiveException: Partition does not have owner. partitionId : 203] with root cause
java.io.IOException: Partition does not have owner. partitionId : 203
at com.hazelcast.client.spi.impl.ClientSmartInvocationServiceImpl.invokeOnPartitionOwner(ClientSmartInvocationServiceImpl.java:43)
at com.hazelcast.client.spi.impl.ClientInvocation.invokeOnSelection(ClientInvocation.java:142)
at com.hazelcast.client.spi.impl.ClientInvocation.invoke(ClientInvocation.java:122)
at com.hazelcast.client.spi.ClientProxy.invokeOnPartition(ClientProxy.java:152)
at com.hazelcast.client.spi.ClientProxy.invoke(ClientProxy.java:147)
at com.hazelcast.client.proxy.ClientMapProxy.getInternal(ClientMapProxy.java:245)
at com.hazelcast.client.proxy.ClientMapProxy.get(ClientMapProxy.java:240)
at com.hazelcast.spring.cache.HazelcastCache.lookup(HazelcastCache.java:139)
at com.hazelcast.spring.cache.HazelcastCache.get(HazelcastCache.java:57)
at org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:71)
If I enabled hot-restart, the issue is solved. But is there a way to resume client application without restarting it and hot-restart is disabled ?
Hazelcast client tries to reconnect to the cluster if the connection drops. It uses ClientNetworkConfig.connectionAttemptLimit and ClientNetworkConfig.connectionAttemptPeriod elements to configure how frequently it will try. connectionAttemptLimit defines the number of attempts on a disconnection and connectionAttemptPeriod defines the period between two retries in ms. Please see the usage example below:
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(5);
clientConfig.getNetworkConfig().setConnectionAttemptPeriod(5000);
Starting with Hazelcast 3.9, you can use reconnect-mode property to configure how the client will reconnect to the cluster after it disconnects. It has three options:
The option OFF disables the reconnection.
ON enables reconnection in a blocking manner where all the waiting invocations will be blocked until a cluster connection is established or failed.
The option ASYNC enables reconnection in a non-blocking manner where all the waiting invocations will receive a HazelcastClientOfflineException.
Its default value is ON. You can see a configuration example below:
ClientConfig clientConfig = new ClientConfig();
clientConfig.getConnectionStrategyConfig()
.setReconnectMode(ClientConnectionStrategyConfig.ReconnectMode.ON);
By using these configuration elements, you can resume your client without restarting it.

Spring JMS CachingConnectionFactory doesn't seem to reconnect on exception

The JMS connection didn't get reconnected when this exception happened:
2014-08-16 10:51:36,724 WARN [TIBCO EMS TCPLink Reader (Server-12486338)] connection.CachingConnectionFactory - Encountered a JMSException - resetting the underlying JMS Connection
javax.jms.JMSException: Connection has been terminated
at com.tibco.tibjms.Tibjmsx.buildException(Tibjmsx.java:502)
at com.tibco.tibjms.TibjmsConnection._onDisconnected(TibjmsConnection.java:2286)
at com.tibco.tibjms.TibjmsConnection$ServerLinkEventHandler.onEventDisconnected(TibjmsConnection.java:341)
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.work(TibjmsxLinkTcp.java:320)
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.run(TibjmsxLinkTcp.java:247)
2014-08-16 10:51:40,286 WARN [TIBCO EMS TCPLink Reader (Server-12494013)] connection.CachingConnectionFactory - Encountered a JMSException - resetting the underlying JMS Connection
javax.jms.JMSException: Connection has been terminated
at com.tibco.tibjms.Tibjmsx.buildException(Tibjmsx.java:502)
at com.tibco.tibjms.TibjmsConnection._onDisconnected(TibjmsConnection.java:2286)
at com.tibco.tibjms.TibjmsConnection$ServerLinkEventHandler.onEventDisconnected(TibjmsConnection.java:341)
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.work(TibjmsxLinkTcp.java:320)
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.run(TibjmsxLinkTcp.java:247)
The exact same error happened a few seconds apart and I wonder if Spring tried to reconnect and gave up after two tries.
I checked Spring source code and didn't find reconnection logic in onException() method in either CachingConnectionFactory or its parent class SingleConnectionFactory. We're using spring-jms 3.1.2 but I looked at the latest Spring source code as well.
Thanks for your help.
I had similar issue where DefaultMessageListenerContainer is unable to reconnect once an exception happens(when TIBCO primary server stops and switch over to secondary TIBCO server).
I was using SingleConnectionFactory and it was causing the issue.
Fetching the connectionFactory directly from Websphere using java:comp/env/jms/TIBCOConnectionFactory resolved this issue.

How and where i can use message store and message processor in ESB?

I have used two instances of WSO2 ESB 4.6 at port number 9443(esb1) and 9446(esb2) and also using Message Broker 2.0.1 at 9444. I am using this url to perform my task :http://wso2.org/library/articles/2013/03/configuring-wso2-esb-wso2-message-broker. I have done the Queue to queue send recieve example using the above link. And everything is working fine. But the problem is when i post any message to esb1, it gets reflected to esb2 since esb2 is working as my subscriber. I want that message store should store that message passed on from esb1 and based on some event it should provide esb2 the messages sent by esb1.
Thanks in advance.
When i make my Massage processor active i keep getting this error continuously :
[2013-04-08 17:58:56,658] ERROR - JobRunShell Job synapse.message.processor.quartz.Processor2-forward job threw an unhan
dled Exception:
java.lang.NullPointerException
at org.wso2.carbon.message.store.persistence.jms.util.JMSUtil.createConnection(JMSUtil.java:46)
at org.wso2.carbon.message.store.persistence.jms.JMSMessageStore.createConnection(JMSMessageStore.java:577)
at org.wso2.carbon.message.store.persistence.jms.JMSMessageStore.getReadConnection(JMSMessageStore.java:517)
at org.wso2.carbon.message.store.persistence.jms.JMSMessageStore.peek(JMSMessageStore.java:239)
at org.apache.synapse.message.processors.forward.ForwardingJob.execute(ForwardingJob.java:88)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
[2013-04-08 17:58:56,669] ERROR - ErrorLogger Job (synapse.message.processor.quartz.Processor2-forward job threw an exce
ption.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
at org.quartz.core.JobRunShell.run(JobRunShell.java:224)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
Caused by: java.lang.NullPointerException
at org.wso2.carbon.message.store.persistence.jms.util.JMSUtil.createConnection(JMSUtil.java:46)
at org.wso2.carbon.message.store.persistence.jms.JMSMessageStore.createConnection(JMSMessageStore.java:577)
at org.wso2.carbon.message.store.persistence.jms.JMSMessageStore.getReadConnection(JMSMessageStore.java:517)
at org.wso2.carbon.message.store.persistence.jms.JMSMessageStore.peek(JMSMessageStore.java:239)
at org.apache.synapse.message.processors.forward.ForwardingJob.execute(ForwardingJob.java:88)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
... 1 more
Looks like there's some issue in your jndi.properties configuration. Make sure the connection factory configuration is valid which seems to have caused the reported issue. In message store implementation, the value of "connection factory" parameter defaults to "QueueConnectionFactory". If you're trying to specify another connection factory with a different name removing the default one (QueueConnectionFactory) from the configuration, make sure you specify the proper connection factory name in the appropriate element of the message store configuration.
Hope this helps!

Resources