2 Replies Latest reply on Mar 31, 2015 3:21 AM by Subhrajyoti Moitra

    Cant get Message API to work.

    Subhrajyoti Moitra Newbie

      Hello,

      I am using Errai 3.1.2.Final for development, wildfly 8.2.0.
      I am using the MessageBuilder and related APIs to send messages. I dont seem to recieve the messages on the MessageCallback at all.

       

      My Entry point

       

      @EntryPoint
      public class LiveShowNotes {
          private static final Logger logger=Logger.getLogger(LiveShowNotes.class.getName());
          private Place defaultPlace=new DashboardPlace();
          @PostConstruct
          public void init(){
      
      
              IClientFactory clientFactory= GWT.create(IClientFactory.class);
              ......
      
      
              }
          @AfterInitialization
          public void afterInit(){
              MessageBus requestDispatcher= ErraiBus.get();
              MessageBuilder
                      .createMessage()
                      .toSubject("CaptureShowNoteService")
                      .with("badgeValue", "somevalue")
                      .with("timestampValue", "so,metimevalue")
                      .with("showNumber","HSn18Shn_100")
                      .with("type", BadgeInfo.Type.MESSAGING.name())
                      .noErrorHandling()
                      .sendNowWith(requestDispatcher);
              logger.info("Errai after initialization..");
          }
      }
      
      

       

       

      My MessageCallback

      @Service
      public class CaptureShowNoteService implements MessageCallback {
        @Inject
          Logger logger;
      
      
          private final RequestDispatcher requestDispatcher;
      
      
          @Inject
          public CaptureShowNoteService(RequestDispatcher requestDispatcher){
              this.requestDispatcher=requestDispatcher;
          }
      
      
          @Override
          public void callback(Message message) {
              System.out.println("Message rx on Subject: "+message.getSubject());
              Map<String, Object> parts = message.getParts();
              if(parts!=null){
                  for (String key : parts.keySet()) {
                      if (parts.get(key) != null) {
                          String value = parts.get(key).toString();
                          System.out.println("Parts key: " + key + ", val: " + value);
                      }
                  }
              }
      
      
              //TODO this same message is to be sent to the DetailedShowNotes screen for the same showNumber.
              MessageBuilder
                      .createMessage()
                      .toSubject("DetailedShowNotesClient")
                      .signalling()
                      .with("badgeValue", RandomStringUtils.random(5,true,true))
                      .with("timestampValue",RandomStringUtils.randomNumeric(5))
                      .with("showNumber",RandomStringUtils.random(5,true,true))
                      .with("type", BadgeInfo.Type.VISUAL.name())
                      .noErrorHandling()
                      .sendNowWith(requestDispatcher);
              System.out.println("DetailedShowNotes message sent...");
      
      
          }
      }
      

       

      My gwt.xml file

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6//EN" "http://google-web-toolkit.googlecode.com/svn/releases/1.6/distro-source/core/src/gwt-module.dtd">
      <module rename-to="LiveShowNotes">
          <inherits name="com.google.gwt.user.User" />
          <inherits name="com.google.gwt.http.HTTP" />
          <inherits name="com.google.gwt.json.JSON" />
          <inherits name="com.google.gwt.i18n.I18N" />
          <inherits name="com.google.gwt.uibinder.UiBinder"/>
          <inherits name="com.google.gwt.logging.Logging"/>   
          <inherits name="org.jboss.errai.enterprise.All" />
          <inherits name="com.google.gwt.user.UserAgent"/>
          <inherits name="com.google.gwt.place.Place"/>
          <inherits name="com.google.gwt.activity.Activity"/>
          <inherits name="org.gwtbootstrap3.GwtBootstrap3"/>
          <inherits name="com.dev.liveshownotes.client.Resources"/>
         <replace-with class="com.dev.liveshownotes.client.local.ClientFactoryImpl">
              <when-type-is class="com.dev.liveshownotes.client.local.IClientFactory"/>
          </replace-with>
          <set-property name="user.agent" value="safari" />
          <set-property name="gwt.logging.enabled" value="TRUE"/>
          <set-property name="gwt.logging.logLevel" value="INFO"/>
          <set-property name="gwt.logging.consoleHandler" value="DISABLED" />
          <set-property name="gwt.logging.developmentModeHandler" value="DISABLED" />
          <!--<set-property name="gwt.logging.firebugHandler" value="DISABLED" />-->
          <set-property name="gwt.logging.hasWidgetsHandler" value="DISABLED" />
          <!-- <set-property name="gwt.logging.popupHandler" value="DISABLED" />-->
          <set-property name="gwt.logging.systemHandler" value="DISABLED" />
          <set-property name="gwt.logging.simpleRemoteHandler" value="DISABLED" />
      </module>
      

       

      On the server none of the messages are being received.

      What am i missing? or doing wrong.?

      Please help. I am stuck with this.

      Thanks a lot in advance.

       

      Thanks,

      Subhro.

        • 1. Re: Cant get Message API to work.
          Christian Sadilek Master

          Hi,

           

          Can you check the JavaScript console in your browser for errors? It seems the client- and server-side bus didn't connect properly.

           

          You can also execute errai_status() and errai_list_services() in the browser to retrieve further information about the message bus i.e. you should see your CaptureShowNoteService under [REMOTES]. See the attached screenshots.

           

          Cheers,

          Christian

           

          Screenshot 2015-03-30 18.36.47.pngScreenshot 2015-03-30 18.37.20.png

          • 2. Re: Cant get Message API to work.
            Subhrajyoti Moitra Newbie

            Thanks a lot Christian, the commands did indeed give some idea of whats wrong. Which was actually nothing. The log messages were somehow not being shown. Wildfly restarts, deletion of log4j.properties and maven clean i think did some trick to get the log messages appear up both on server side.

             

            Things are working as expected. Thanks again for lookin into this.

             

            Regards,

            Subhro.