4 Replies Latest reply on Aug 4, 2011 7:19 AM by Serkan Eskici

    MDB and Seam lifecycle issues

    Vinicius Carvalho Newbie

      Hello there! I know theres an issue for this : https://jira.jboss.org/jira/browse/JBSEAM-2286, but has anyone succeeded in using MDB as Seam components and having it ready (by that I mean with all dependencies injected) if the queue already have messages on it?


      When I start receiving messages Seam did not inject components inside my class, So I get an error complaining about trying to use a component outside the context :(


      I tried to setup my component by using @Create and setting it as the listener for the queue:



      @Create
      public void setup(){
      @Create
           public void setup() throws Exception{
                InitialContext ctx = new InitialContext();
                Destination destination = (Destination)ctx.lookup("queue/myQueue");
                consumer = queueSession.createConsumer(destination);
                
                consumer.setMessageListener(this);
           }
      }
      



      I know it was a naive approach, since the listener would be called outside the seam scope :(, but was a try :(


      What I don't get is, why can't seam have a Listener type component? So by just using @Listener for instance on my component it would be managed by seam.


      I solved the problem in a very ugly and shameful way (created an internal class and passed all the dependencies I needed to it on the constructor), is there a better way to deal with that?