7 Replies Latest reply on Feb 6, 2014 10:31 AM by mbarkley

    Errai messaging firing callback twice.

    rathiandi

      I am firing an event from server as below :

      MessageBuilder.createMessage()

              .toSubject("PlayListRefreshService").signalling()

              .with("Key", "ABC")

              .with("Identifier", "XYZ")

              .noErrorHandling().sendNowWith(dispatcher);

       

      And have handler at client like below; please this code is inside a widget's constructor.

      ErraiBus.get().subscribe("PlayListRefreshService", new MessageCallback() {

        @Override public void callback(Message message) {

             logger.info("Here I am !!");

        }

        });

       

      Log message "Here I am !!" is being displayed twice. Appreciate any clues?

       

      Thanks,

        • 1. Re: Errai messaging firing callback twice.
          mbarkley

          Hi Amit,

           

          Do you also have Errai CDI in your project? If so, make sure that do not have this in your web.xml inside the ErraiServlet:

           

          <init-param>
             <param-name>auto-discover-services</param-name>
             <param-value>true</param-value>
          </init-param>
          

           

          This should only be in your web.xml if you are not using a server-side CDI container. Otherwise, it can cause duplicate instances of server-side Service classes to run.

           

          Cheers.

          • 2. Re: Errai messaging firing callback twice.
            rathiandi

            Yes I do have Errai CDI. I am using complete jee stack.

             

            Yes, I do have this entry in my web.xml and if it didn't work. if i remove this entry - Entire messaging framework stops working and throws below error: 

             

            Error: no subscribers to deliver to for subject:

            • 3. Re: Errai messaging firing callback twice.
              mbarkley

              Do you have a beans.xml in your WEB-INF folder? It doesn't need to have much in it, but it needs to be there for containers such as Weld to manager your Service classes. For example, this is the beans.xml in errai-tutorial.

              • 4. Re: Errai messaging firing callback twice.
                rathiandi

                Yes; I do have that file under WEB-INF but it seems it's not working.  Below are my env details, not sure if this will be helpful to point me in right direction.

                Eclipse + JBoss Tools + Google GWT plugin + Jetty (Default GWT server)

                 

                I Hope default GWT server is not causing these issues?

                • 5. Re: Errai messaging firing callback twice.
                  mbarkley

                  Hmm, I was assuming you were using Jboss AS, but Jetty shouldn't be a problem provided you're deploying your own CDI container. Here are instructions on deploying Weld with Jetty.

                  • 6. Re: Errai messaging firing callback twice.
                    rathiandi

                    Adding weld didn't help. As soon as i comment out "auto-discover" messaging stops working completely.  I wanted to to use JbossAS but documentation was little cumbersome. I know GWT before and feel very conformable using build-in Jetty as "Run-As" web application from GWT plug-in.  I don't like dev-mode that start another window to lunch web browser and no-server options introduce more problem then it solves. But hey! It's just me.

                    Also, I don't have prior exp with JBoss. Not sure how hard would it be to setup single instance on ubuntu with production configuration. I even wanted to use Openshift but that turned out another configuration nightmare or may be i was doing something stupid.

                     

                    Anyways, one more questions regarding messaging - I start application with option " -Derrai.tools.bus_monitor_attach=true" and that brings up screen with messaging internals and i see following services and not sure regarding following services:

                         a. AuthorizationService

                         b. AuthenticationService

                         c. BusService

                         d. ServerEchoService

                     

                    Also, i don't see my server listed twice in this UI so I am assuming my configuration is right. It could be a bug in system that deliver or call Callback twice. 

                     

                    Really appreciate all your help.

                    • 7. Re: Errai messaging firing callback twice.
                      mbarkley
                      I wanted to to use JbossAS but documentation was little cumbersome.

                      Yeah, that's understandable. Fortunately, we're working on the issue now with a soon to be announced Forge 2.0 plugin. With the plugin you'll be able to setup an Errai project running on Jboss using Eclipse with a few button clicks. So if you'd be interested in trying that, stay tuned to the Errai twitter/blog.

                       

                      But for the time being I have a two more suggestions:

                      • If you haven't already, try comparing your jetty setup to one of our demos, such as this one. In particular, you may want to take a close look at it's WEB-INF folder.
                      • Try printing some stack traces in your classes when and where they're being created. I'd suggest doing this for both the sending and receiving classes, in their sending and receiving methods respectively as well as their constructors. If you paste those here I will take a look.