JMS queue stucks on MDB using Seam
drlzzt Jul 28, 2010 5:00 AMHello,
maybe someone help me with configuration of JMS queues using Seam and MDB as a receiver. Problem is when I send the message to the queue everything is ok but onMessage() it stuck (more specifically when tries to getObject) and this process is uncontrollable (happens randomly). If i make Thread.sleep for some miliseconds it's ok and no problems but this is not the solution i would prefer. Seems like the same problem which was wis Seam remoting and server faster than the client :). Here's the configuration maybe i missed something and now i get such situation.
components.xml
<jms:queue-connection queue-connection-factory-jndi-name="java:/JmsXA"/> <jms:managed-queue-sender name="asyncOperationSender" auto-create="true" queue-jndi-name="queue/asyncOperations"/>
dispatcher
@Name("asyncOperationDispatcher") @AutoCreate public class AsyncOperationDispatcher { @In private QueueSender asyncOperationSender; @In(create = true) private QueueSession queueSession; /** * @param transport */ public void publish(StateEngineTransport transport) { try { asyncOperationSender.send(queueSession.createObjectMessage(transport)); } catch (Exception ex) { } finally { try { if (asyncOperationSender != null) { asyncOperationSender.close(); } if (queueSession != null) { queueSession.close(); } } catch (JMSException e) { } } } }
Reciever with a Thread.sleep which negates hanging of whole application server
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/asyncOperations") }) @Name("asyncOperationsProcessorMDB") public class AsyncOperationsProcessorMDB implements MessageListener { @Logger private Log logger; @In private OperationProcessor operationProccesor; /** @see javax.jms.MessageListener#onMessage(javax.jms.Message) */ @Override public void onMessage(Message message) { try { Thread.sleep(500); Object messageObject = ((ObjectMessage)message).getObject(); Operation operationMsg = (Operation)messageObject; PerformOperationValue po = null; try { // perform operation po = operationProccesor.process(operationMsg); } catch (Exception e) { // need to append default error or throw the exception } message.acknowledge(); } catch (JMSException ex) { // TODO rollback transaction logger.error("AsyncOperationsProcessorMDB.catch exception" + " during aknowledgement of JMS message ", ex); }catch (InterruptedException ex){ } } }
If Thread.sleep is removed queue hangs and all application server hangs with a need to restart (any deployed application won't respond) and in log a get this information after a while which is quiet obvious because transaction timeouts if nothing happens.
16:29:22,492 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.Transacti nReaper_18] - TransactionReaper::check timeout for TX a040129:d33e:4c4d8bd7:eb n state RUN 16:29:22,493 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.Transacti nReaper_18] - TransactionReaper::check timeout for TX a040129:d33e:4c4d8bd7:ec n state RUN 16:29:22,494 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicActi n_58] - Abort of action id a040129:d33e:4c4d8bd7:eb invoked while multiple thre ds active within it. 16:29:22,495 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAc ion_2] - CheckedAction::check - atomic action a040129:d33e:4c4d8bd7:eb aborting with 1 threads active! 16:29:22,495 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.Transacti nReaper_7] - TransactionReaper::doCancellations worker Thread[Thread-10,5,jboss successfully canceled TX a040129:d33e:4c4d8bd7:eb 16:29:22,496 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicActi n_58] - Abort of action id a040129:d33e:4c4d8bd7:ec invoked while multiple thre ds active within it. 16:29:22,496 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAc ion_2] - CheckedAction::check - atomic action a040129:d33e:4c4d8bd7:ec aborting with 1 threads active! 16:29:22,499 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.Transacti nReaper_7] - TransactionReaper::doCancellations worker Thread[Thread-10,5,jboss successfully canceled TX a040129:d33e:4c4d8bd7:ec
Such feeling that message is put to queue but not fully yet and AS already calls MDP onMessage and tries to getObject() and everything freezes than. If i halt before call than everything works but this doesn't solve the cause of the problem ... :(