4 Replies Latest reply on Apr 5, 2006 10:37 AM by gavin.king

    Seam and MDB

    prp

      Can I access seam components from MDB's or doesn't this make any sense?

        • 1. Re: Seam and MDB
          mirko27

          what do you mean with MDB? I`m not very updated at termins.

          • 2. Re: Seam and MDB
            gavin.king

            Yes, you can, but not all Seam contexts will be available.

            I think you need to use Seam CVS for this to work.

            In future, I will implement stuff to let you pass Seam conversation ids in the message header, which will allow all Seam contexts to be used from an MDB.

            • 3. Re: Seam and MDB
              prp

               

              "gavin.king@jboss.com" wrote:
              Yes, you can, but not all Seam contexts will be available.

              Can you give an example that shows how to use this?

              I tried to call Contexts.getSessionContext() or Component.getInstance("mySeamComponent", false) from within my MDB but both methods return null. Anotating the MDB into a Seam component also doesn't help.

              I used the latest nightly build.

              /*
               *@Name("myMDB")
               *@Interceptors(SeamInterceptor.class)
               *@Scope(ScopeType.STATELESS)
               */
              @MessageDriven(activationConfig =
              {
               @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
               @ActivationConfigProperty(propertyName="destination", propertyValue="queue/testJms")
              })
              public class MyMDB implements MessageListener {
               ...
               @In private Context statelessContext;
               private Context sessionContext;
              
               public void onMessage(Message msg) {
               sessionContext = Contexts.getSessionContext();
               log.info("StatelessContext = " + statelessContext); //returns null
               log.info("SessionContext = " + sessionContext); //returns null
               }
              
              }


              • 4. Re: Seam and MDB
                gavin.king

                Yes, of course there can be no session context in an MDB ;-)