5 Replies Latest reply on Aug 9, 2008 7:43 PM by pmuir

    FacesMessage does not not display my message

    fleury

      Hey,


      I'm calling an asynchronous method and I would like to notify the client that the method has ended by displaying a message on the
      screen. The problem is that the message is not displayed.
      I'm using JMS with a message-driven bean and a stateful bean :



      @MessageDriven(activationConfig = {
                @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
                @ActivationConfigProperty(propertyName="destination", propertyValue="queue/pQueue")})
      
      @Name("ProcessMessageListener")
      public class ProcessMessageListener implements MessageListener {
      
           public void onMessage(Message m) {
                try {
                     FacesMessages.instance().add("message id = " + m.getJMSMessageID()); //THIS MESSAGE IS NOT DISPLAYED 
                     
                } catch (JMSException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                }
           }
      }
      
      
      @Stateful
      @Name("resourceManager")
      @Scope(ScopeType.SESSION)
      
      
      public class Resource implements IResource, Serializable {
               @In(create=true)
            private transient QueueSender queueSender; 
           
            @In(create=true)
            private transient QueueSession queueSession;
           
           public void delete() {
                 try
                  {
                     queueSender.send( queueSession.createTextMessage("Resource has been deleted"));
                  }
                  catch (Exception ex)
                  {
                  ex.printStackTrace();
                     throw new RuntimeException(ex);
                  } 
          }
      }
      
      public interface IResource {
      
           @Asynchronous
           void delete();
      
           void destroy();
      }




      Thank you for your help.


      LF


      Using seam-1.2.1-GA



        • 1. Re: FacesMessage does not not display my message
          admin.admin.email.tld

          I have yet to use JMS/MDB with Seam, but...


          Are you using rich:message(s) or h:message(s) on your JSF/facelet?  is there any messages queued but not displayed in the console/server.log?  h:message(s) you have to manually reRender to see the message(s).


          post your xhtml.


          also, consider upgrading to Seam 2.x.

          • 2. Re: FacesMessage does not not display my message
            bravocharlie.seam.signup.benny.me.uk

            Your message driven bean is outside scope of FacesMessages (conversation).  So you are adding a FacesMessage to a temporary conversation context which has no relation to the page the user is viewing.


            Consider raising an event from your MDB, and observing it in your Resource class which sets a flag.  Then use a4j:poll to check for flag status.


            Be careful though, as MDB is outside even session scope, so there is no connection between the MDB and a particular user session.

            • 3. Re: FacesMessage does not not display my message

              Hi,
              Once you have solved the scope problems, if you keep on having problems to display messages have a look to this previous thread


              Btw, other way to create a FacesMessage:


              FacesMessage message = FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR,"your message");
              




              • 4. Re: FacesMessage does not not display my message
                admin.admin.email.tld

                Good call.


                here's an excerpt regarding MDB's from Seam in Action:


                Although an MDB can act as a Seam component, the dynamics are very different. Message-driven beans can’t be instantiated by the application, which means they’re never associated with a context. Instead, they listen for messages on a JMS topic or queue and get instantiated by the EJB 3 container to handle a message when it arrives. They can, however, take advantage of bijection.



                There was very little coverage of MDB's in the Seam ref manual or Seam in Action (or even the Yuan or Apress books as I recall)...


                Seems like this should be a sticky or best practice on how to effectively use MDB's in Seam apps...

                • 5. Re: FacesMessage does not not display my message
                  pmuir

                  Actually, they are contextual (stateless).