Hornetq - Producers blocked in a bean managed transaction
manu29585 Jan 31, 2017 12:06 AMHello All,
But. we have a bad situation in our production system.
We are using 2.1.2.Final version of Hornetq in JBoss 6.1.0 final.
Currently, we are reusing the connection and session and are created as shown below:
cachedQueueConnection = cachedConnectionFactory.createConnection();
// KEY - register for exception callbacks
cachedQueueConnection.setExceptionListener(new ExceptionJMSListenerImpl());
session = cachedQueueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(cachedQueue);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
We are pushing data to the queue as shown below:
ObjectMessage contextMessage = session.createObjectMessage();
- contextMessage.setObject(context);
- producer.send(contextMessage);
Application runs fine for few days and we have a situation sometimes that, "producer.send(contextMessage);"
is getting blocked. Its returning only after sometime (sometimes ~15s to 15 min).
This pushing to the queue happens within a bean managed transaction. (This transaction includes database operation such as update, insert and delete as well and as a final action, this data of collected information on what is being done is pushed to the queue )
This inturn makes the transaction inactive since the locks held by the transaction will not be committed.
There are 2 typical scenarios out of this.
It is observed sometimes that, eventhough producer call is not returned (Thread goes to the waiting state and returns later), consumer on the other end which is a MDB listening to the queue and responding to onMessage:
MDBean implements MessageListener{
public void onMessage(Message msg) {
ObjectMessage objMsg = (ObjectMessage) msg;
- objMsg.getObject();
}
}
Sometimes, eventhough, producer.send() has not returned, on the other end, message is being already processed.
But, on the other scenario, message is not consumed.
Is there anything wrong in the code? We are failing to understand why producer is getting blocked!
Also, since this problem is appearing only on the production system, it would be great, if any of you can give a hint on generating additional logs which will enable debugging this problem.
Any hints would really be helpful.
Thanks a lot in advance!