[jboss-user] [Messaging, JMS & JBossMQ] - Synchronizing MessageDrivenContext

amadeuz do-not-reply at jboss.com
Tue Aug 22 21:57:09 EDT 2006


I have an issue of JBoss terminating (rolling back) the context of the message driven bean when large amount of MDB instances are actively processing the message and gives me the following exceptions:

Caused by: org.hibernate.TransactionException: could not register synchronization with JTA TransactionManager
  | 	at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:160)
  | 	at org.hibernate.jdbc.JDBCContext.<init>(JDBCContext.java:79)
  | 	at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:266)
  | 	at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:436)
  | 	at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:460)
  | 	at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:468)
  | 	at com.quinstreet.dms.leadprocessor.util.hibernate.DbConfig.getSession(DbConfig.java:176)
  | 	... 30 more
  | Caused by: javax.transaction.RollbackException: Already marked for rollback
  | 	at org.jboss.tm.TransactionImpl.registerSynchronization(TransactionImpl.java:717)
  | 	at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:149)
  | 	... 36 more

This is due to context being rolled back in the middle of some processing and the system attempt to obtain new connection. I'm using Hibernate to query and in certain case update multiple instances of DBs. I have tried using XA 3 Phase commit JDBC driver but didn't work for me and I decided to try to use the sync block in my code:

        // Make sure no body modify the context of this process during processing
  |         synchronized (context) {
  |             try {
  |                 if (!context.getRollbackOnly()) {
  |                     Processor.process(message, cacheName);
  |                 } else {
  |                     return;
  |                 }
  |             } catch (Exception e) {
  |                 String exceptionMsg = new StringBuilder().append("Exception occured while processing message: ")
  |                         .append(message).toString();
  |                 ExceptionHandler.handle(e, exceptionMsg, MessageProcessorHelper.getMessageInfo(message));
  |                 return;
  |             }
  |         }

I did this because there are multiple complex sequences of queries that I perform within Processor.process() that makes it hard to trace whether context has been rolled back before obtaining connections (I may be wrong but I will have to pass MessageDrivenContext instance to all of the connection obtaining class - I'm not using Spring).

Now the sync block works great, until a restart is initiated. When some messages are being processed while a server restart is initiated, certain things are undeployed (connections, ejbs, etc) and it looks like my MDB is waiting for the undeployed piece and hangs while the restart is waiting for the context to be freed which causes me to have the following warnings:

[org.jboss.ejb.plugins.AbstractInstanceCache] Unable to passivate due to ctx lock, id=11674561

This is BAD because it prevents JBoss to shutdown gracefully, I would have to kill the process to restart it.

I'm aware that this might not be the best solutions so please let me know if there's anyway I can get around the above issues. Any constructive response will be highly appreciated! 

-luke-



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966844#3966844

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966844



More information about the jboss-user mailing list