6 Replies Latest reply on Nov 22, 2011 8:50 PM by aamir.pk

    Working MDB example in JBoss 7.0.1?

    aregan

      Here's an EJB3 MDB that used to work for me in JBoss 5.1:

       

      {code:java}    @TransactionAttribute( TransactionAttributeType.NOT_SUPPORTED )

          @org.jboss.ejb3.annotation.Depends("jboss.messaging.destination:service=Topic,name=IncomingArticleNotifications")

          @MessageDriven(

              activationConfig = {

                  @ActivationConfigProperty( propertyName="destinationType", propertyValue="javax.jms.Topic"),

                  @ActivationConfigProperty( propertyName="destination", propertyValue="topic/IncomingArticleNotificationsDest"),

                  @ActivationConfigProperty( propertyName="subscriptionDurability", propertyValue="Durable"),

                  @ActivationConfigProperty( propertyName="messageSelector", propertyValue ="type='IncomingArticleNotification'")

              }

          )

          public class IncomingArticleHandler implements MessageListener

          {

              [ ... ]

          }{code}

       

      Try as I might, I can't migrate this to JBoss 7.0.1. JMS is set up OK, and I can publish to the destination OK (from my main JAR), but my EJB listener just isn't listening. I get no deploy or runtime errors for my EJB / WAR / EAR:

       

      {code}    01:02:40,600 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) Starting deployment of "product-ear-1.0-SNAPSHOT.ear"

          01:02:41,752 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "product-ejb-1.0-SNAPSHOT.jar"

          01:02:41,753 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "product.war"{code}

       

      I've also fixed the JNDI names, as per instructions, so here's what I have now:

       

      {code:java}    // Ignore for now: @TransactionAttribute( TransactionAttributeType.NOT_SUPPORTED )

          // Ignore for now: @ResourceAdapter("ejb3-rar.rar")

          @MessageDriven(

              activationConfig = {

                  @ActivationConfigProperty( propertyName="destinationType", propertyValue="javax.jms.Topic"),

                  @ActivationConfigProperty( propertyName="destination", propertyValue="java:/topic/IncomingArticleNotificationsDest"),    // updated

                  // Ignore for now: @ActivationConfigProperty( propertyName="subscriptionDurability", propertyValue="Durable")

                  // Ignore for now: @ActivationConfigProperty( propertyName="messageSelector", propertyValue ="type='IncomingArticleNotification'")

              }

          )

          public class IncomingArticleHandler implements MessageListener

          {

              [ ... ]

          }{code}

       

      Setting all loggers to ALL before deploying reveals that the only time my MDB classes are mentioned is when the

      org.jboss.vfs.util.SuffixMatchFilter sees them - that can't be good.

       

      I've been following the issue of MDB support since 7.0.0 (https://issues.jboss.org/browse/AS7-455) and have read through dozens of JIRAs, not to mention the migration guide, EJB3 docs and so on, but I'm left confused. I know MDBs *should* work in 7.0.1, but is the above doable? I think mine is quite a simple case, so does anyone have a simple working example, a single document that states exactly what does / doesn't work in 7.0.1, or a migration guide?

       

      I can deploy a dummy {code:java}@Stateless{code} with no problems, but no combination of {code:java}@MessageDriven{code} / {code:java}@ActivationConfigProperty{code} has had any effect at all (bodging the destinationType to `javax.jms.XXX` produces no errors!). I've tried setting the destination property to all possible JNDI combinations.

       

      I've checked my 'standalone.xml' against 'standalone-preview.xml' and there are no substantial differences.

      .

        • 1. Re: Working MDB example in JBoss 7.0.1?
          aregan

          I finally managed to solve this myself. JNDI was a red-herring. I didn't need to upgrade to JBoss 7.1.0 alpha, nor did I need to change my project to use JEE 6 deployment (moving my EJBs into the WAR).

           

          In the end, all I needed to do was turn off JBoss's EJB3 "lite" mode (this was set to true in the standalone-preview.xml I copied from). Presumably MDBs are not supported in that mode. As soon as I did this, my MDBs became visible.

          • 2. Re: Working MDB example in JBoss 7.0.1?
            jaikiran

            Andrew Regan wrote:

             

             

             

            In the end, all I needed to do was turn off JBoss's EJB3 "lite" mode (this was set to true in the standalone-preview.xml I copied from).

            Are you sure you were using a clean installation of JBoss AS? The standalone-preview.xml doesn't have that set to true.

            • 3. Re: Working MDB example in JBoss 7.0.1?
              aregan

              You're right, having had a look, 'lite' isn't set by default in standalone-preview.xml. Can't explain how it got introduced, unless I mistakenly pulled it in from standalone-ha.xml, or from an online XML snippet. Sorry for any confusion!

              • 4. Re: Working MDB example in JBoss 7.0.1?
                aamir.pk

                Then how did you manage to solve this issue? I am also facing the same problem and trying to solve it for last 24 hours or more.

                • 5. Re: Working MDB example in JBoss 7.0.1?
                  aregan

                  Make sure JBoss's EJB3 "lite" mode is not set. Are you sure you're getting the same problem?

                  • 6. Re: Working MDB example in JBoss 7.0.1?
                    aamir.pk

                    Thanks Andrew for your quick reply.

                     

                    Yes same issue.

                     

                    Not only MDB is not working but also I am unable to send and receive messages on a JMS topic (I am not sure that the problem is with sending or with receiving as I don't get any error). I have created two session bean methods, one to receive with consumer.receive(timeout) and another to send. I inoke receive method and while it is waiting for timeout I call the method that send the message on topic, but in result receiving method keeps receiving untill it gets timed out.

                     

                    Acutally the reason I was doing MDB is just to isolate the above issue and check weather sending is working correct or not.

                     

                    Regards