2 Replies Latest reply on Sep 7, 2012 2:05 PM by mdhirsch30345

    Unable to send messages on a client-to-client errai bus

    mdhirsch30345

      I'm trying to send messages on the errai bus between object in a single client.  There is no server-side to this app.  I'm unable to send because I get the NoSubscribersToDeliverTo error:


      org.jboss.errai.bus.client.api.base.NoSubscribersToDeliverTo: no subscribers to deliver to for subject:

       

      Since there is no server I have to configure things right, I know.  I added this to my main page:

       

          <!-- No server side communication -->

          <script type="text/javascript">

              erraiBusRemoteCommunicationEnabled = false;

          </script>

       

      Then, in my web.xml I have

          <servlet>

              <servlet-name>ErraiServlet</servlet-name>

              <servlet-class>org.jboss.errai.bus.server.servlet.DefaultBlockingServlet</servlet-class>

              <init-param>

                  <param-name>auto-discover-services</param-name>

                  <param-value>true</param-value>

              </init-param>

              <load-on-startup>1</load-on-startup>

          </servlet>

      and also

          <servlet-mapping>

              <servlet-name>ErraiServlet</servlet-name>

              <url-pattern>*.erraiBus</url-pattern>

          </servlet-mapping>

      which I found in other answers to this problem.

       

      I have an object that subscribes to the bus.  In the debugger I can see the bus.subscribe() code run.

       

      Then another object tries to send to this bus and I get the error above.

       

      Once again, I think I'm missing something simple.  Possible there is another configuration I'm missing, but I don't know what.

       

      What have I missed?

       

      Thanks,

       

      Michael

        • 1. Re: Unable to send messages on a client-to-client errai bus
          cbrock

          It may be that you're trying to send a message to the bus before the bus is ready. You can use InitVotes.registerInitCallback(Runnable) to create a callback to initialize your app after thebus is done loading.

          • 2. Re: Unable to send messages on a client-to-client errai bus
            mdhirsch30345

            Thanks for the reply, Mike.

             

            I don't think I'm sending the message too quickly, unless the bus extraordinarily slow.  I'm sending the message inresponse to a button click after filling out two text fields.  I'm not that fast a typist!  Is there a command I needed to run to initialize the bus?  I'm not doing any server-side bus usage, so maybe I need to tell it to initialize?

             

            Strangely, I got things to work with events instead of the bus.  Since I thought the events infrastructure was built on the bus I didn't expect it to work.  Instead, it not only worked but was the easiest thing to implements in my 2 weeks of struggle with Errai.  God job!

             

            I didn't have to do anything to get the events to work.  In particular, I didn't need to change my web.xml.

             

            Thanks agian,

             

            Michael