2 Replies Latest reply on May 29, 2009 6:15 PM by Jon Hatfield

    Message Driven Bean as Seam component

    Jon Hatfield Newbie

      Hi,


      I have an MDB that is working as an EJB component (@MessageDriven), called by a conversational Seam component. I would like to make it a Seam component and inject another Seam component into it.


      Please could someone advise as to how to annotate the MDB and injected bean? I have tried several variations and think they should probably both be @Stateless, though the introduction of even just a @Name tag to the MDB to make it a Seam component disables the Messaging function, regardless of any additional bean that is injected into this MDB.


      Also, is the entitymanager valid when part of a Seam component that is injected into an MBD? Similar examples suggest it is, even though using the entitymanager cannot be used as a variable in the MDB (its extended persistence context is only allowed in stateful session beans).


      Thanks,
      Jon

        • 1. Re: Message Driven Bean as Seam component
          Nikolay Elenkov Master

          All you need is MessageDriven and Name. The messaging function should work as before,
          you probably have some other configuration problem.


          What do you mean by:



          I have an MDB that is working as an EJB component (@MessageDriven), called by a conversational Seam component.


          Your MDB should receive messages and that's it. How are you calling it?
          Or by 'calling' you mean 'sending a message'?


          And what do mean by is the EntityManager valid? You can only inject event and application scoped components
          in an MDB, so if you are thinking about injecting the SMPC, that won't work.


          HTH


          • 2. Re: Message Driven Bean as Seam component
            Jon Hatfield Newbie
            Thanks for the reply. I have got this working now. I am injecting a stateless bean that has an entitymanager marked with @PersistenceContext(type=PersistenceContextType.TRANSACTION). It was previously PersistenceContextType.EXTENDED which was incompatible with the context of an MDB. I can now do EJB database transactions in the MDB.