2 Replies Latest reply on Feb 18, 2011 10:36 PM by cdollar393

    MDB calling EJB -- Message redelivery question


      Here is my scenario: I have an .ear application with a security domain. One of the EJB3 beans puts a JMS message on a queue as part of its operation. That JMS message is consumed by a MDB, which in turn calls a different EJB3 method as part of its onMessage() method.


      The EJB that gets called by the MDB looks something like this:





      public class SomeEJB implements SomeInterface {



           public void foo() {





      Nothing very special there. The MDB that calls this EJB looks like:



      @MessageDriven(activationConfig =









      public class PaymentCaptureProcessorBean implements MessageListener {

           public void onMessage(Message arg0) {

                // do an EJB lookup and call foo()




      There's nothing too fancy there either. This setup works fine, just as expected.


      Here's my question... in my MDB if I change @RunAs("admin") to @RunAs("normalUser") (so I've coded an obvious mistake by telling the MDB to run as a role that ultimately is not allowed to call the EJB method) then when the MDB goes to call the EJB foo() method I get these exceptions:



      15:27:45,350 ERROR [org.jboss.ejb3.tx2.impl.CMTTxInterceptor] javax.ejb.EJBAccessException: Caller unauthorized

      15:27:45,350 ERROR [org.hornetq.ra.inflow.HornetQMessageHandler] Failed to deliver message: javax.ejb.EJBAccessException: Caller unauthorized




      I expect this behavior too. But what I'm also seeing in this case is the MDB now continues to try to consume the message over and over again in an endless loop. I added some code to check getJMSRedelivered() and that returns false for each message that tries to be re-consumed.


      This makes me think that the issue is not with HornetQ (if it was I would expect getJMSRedelivered() to return true, and in that case if I saw more than 10 re-delivery attemtps then I would suspect this to be an issue with HornetQ), but since getJMSRedelivered() always returns false it seems like this isn't a true message re-delivery, but more like its trying the initial delivery over and over again.


      Now granted I clearly coded in error, but the effect of the endless loop of the MDB getting the message trashes the server so hard that the only thing to do to get it to stop is to shut it down.


      So is this expected behavior?