1 Reply Latest reply on Mar 8, 2012 8:25 PM by pauld1119

    MessageDrivenContext not being set

      I'm trying to implement a Spring MDB.

      I've tried 2 different ways.  1, extending AbstractJmsMessageDrivenBean, and the other, implementing MessageListener and MessageDrivenBean.  Both approaches provide a setMessageDrivenContext(MessageDrivenContext ctx).

      I'm getting my messages, but setMessageDrivenContext is never invoked.  I've found a related issue https://issues.jboss.org/browse/AS7-1783, but adding the @Resource annotation is not working for me either.

       

      Spring example: 

       

      public class RepositoryNotificationListenerBean  extends AbstractJmsMessageDrivenBean {

       

      public void ejbRemove() throws EJBException { 
      }

       

      @Resource(type=EJBContext.class)
      public void setMessageDrivenContext(MessageDrivenContext ctx)
         throws EJBException { 
        super.setMessageDrivenContext(ctx); 
      }

       

      @Override
      protected void onEjbCreate() {
        }

      public void onMessage(Message msg) {
        log.debug(msg);
        //do something
      }
      }

       

      I need access to the context so I can do a rollback if necessary.

        • 1. Re: MessageDrivenContext not being set

          It seems this is just an issue trying to utilize Spring JMS.  I have confirmed that the @Resource work around does indeed work for an ejb MDB.  Does anyone know if there is some issue with using JBoss AS 7 and Spring JMS?  It doesn't appear that the MDB lifecyle is being completed for a Spring managed MDB.