9 Replies Latest reply on Dec 6, 2007 3:13 PM by Chris Kopec

    Stupid Bisocket question, how do I do invocations on the cli

    Ian Nelson Newbie

      I have set up a bisocket and I'm able to perform invoations on my client against my server and the listener I attached to my connector is invoke and that's all fine and dandy. How can I do invocations against my client?

      I've been trying to mine my way through the tests and such and it's not clear to me.

      thanks,

        • 1. Re: Stupid Bisocket question, how do I do invocations on the
          Ron Sigal Master

           


          How can I do invocations against my client?


          Sorry, I don't know what you mean. Could you elaborate? Thanks.

          • 2. Re: Stupid Bisocket question, how do I do invocations on the
            Ian Nelson Newbie

            So I have my clients and server communicating with bisocket. I create a Connector, then my clients create a Client object, connect and add an InvokerCallbackHandler to it. Then when I wish to perform a task on the server I can do a client.invoke(...) and my ServerInvocationHandler receives the invoke does some work and and return some object.

            What it looks like I need to do is after my client connects, I need to create a Connector object on my client, add an InvokerCallbackHandler to it and then have my server create a new client from its side. Is that right?

            • 3. Re: Stupid Bisocket question, how do I do invocations on the
              Ian Nelson Newbie

              I have some more information.

              On my server side, I take my callbackInvoker and I do:

              ServerInvokerCallbackHandler myCaller = (ServerInvokerCallbackHandler)myCallbackInvoker;
              try {
              myCaller.getCallbackClient().addListener(new MyClientCallbackHandler());
              } catch(Throwable ee) {
              log.error("Error attaching callback handler!", ee);
              }
              }

              and I always get an error that I cannot do that since there isn't a listener registered with it.

              How do I create a Connector on the client side and associate it? In one of the tests is simply creates a connector with a URL "bisocket://:1"

              • 4. Re: Stupid Bisocket question, how do I do invocations on the
                Ian Nelson Newbie

                Is there a clean bisocket example anywhere?

                • 5. Re: Stupid Bisocket question, how do I do invocations on the
                  Ron Sigal Master

                  Ok, I understand the question. Remoting doesn't currently have a built-in server-to-client invocation facility directly analogous to the client-to-server invocation facility. Of course, you can always explicitly create a Connector on the client side and a Client on the server side.

                  On the other hand, Remoting has a server-to-client callback facility. Callbacks are like invocations but more general, in the sense that they can be stored on the server until the client retrieves them. One way to set up a callback connection is to create a Connector on the client side and pass an InvokerCallbackHandler and the Connector's InvokerLocator to Client.addListener(). Or, you could simply pass an InvokerCallbackHandler to Client.addListener() and Client will create the Connector for you. In the course of executing Client.addListener(), the server will call ServerInvocationHandler.addListener(). That's not something you should do yourself.

                  You should look at Section "5.6. Callbacks" of the Remoting Guide (http://labs.jboss.com/jbossremoting/docs/guide/index.html).

                  As for a bisocket example, well, it's somewhere on my list of things to do (JBREM-773), but, until then, you should look at the example in the org.jboss.remoting.samples.callback package, which uses the socket transport. Setting up a callback connection is largely the same for all transports. There are a few configuration differences between socket and bisocket, but the main one is the use of the org.jboss.remoting.transport.bisocket.Bisocket.IS_CALLBACK_SERVER parameter on the client side if you want the callback server to avoid the use of ServerSockets. (If you don't care about that, then you should be using the socket transport.) For example,

                   InvokerCallbackHandler callbackHandler = new SampleCallbackHandler();
                   HashMap metadata = new HashMap();
                   metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
                   client.addListener(callbackHandler, metadata);
                  


                  • 6. Re: Stupid Bisocket question, how do I do invocations on the
                    Ian Nelson Newbie

                    Thank you for the response. Where are you located Ron? I owe you some beers. Next time I'm in your neck of the woods or you're in Colorado I should buy you some.

                    thanks again.

                    • 7. Re: Stupid Bisocket question, how do I do invocations on the
                      Ron Sigal Master

                      LOL.

                      I'm a Red Sox fan. They might not let me in Colorado. :-)

                      And don't tell my neighbors - I live in New York.

                      • 8. Re: Stupid Bisocket question, how do I do invocations on the
                        Ian Nelson Newbie

                        haha.

                        New Yorkers are okay, they are always welcome. We welcome Bostonians too, we welcomed Ray Bourque to town with open arms and then retired his number and let him drink out of our big shinny hockey cup. Full credit to the Sox winning but Ray still had to come here for his glory. haha



                        • 9. Re: Stupid Bisocket question, how do I do invocations on the
                          Chris Kopec Newbie

                          Although a BiSocket example hasn't been implemented. I have found that the unit tests work just as well as an example. There are a whole set of unit tests for the BiSocket (see BiSocketTestCase.java).