4 Replies Latest reply on Apr 5, 2006 10:37 AM by Gavin King

    Seam and MDB

    prp prp Newbie

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

        • 1. Re: Seam and MDB
          Mirko Adari Novice

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

          • 2. Re: Seam and MDB
            Gavin King Master

            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 prp Newbie

               

              "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 Master

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