Package org.jboss.remoting

Examples of org.jboss.remoting.Client.invokeOneway()


         client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);

         client.connect();

         client.invokeOneway("blip");

         // make sure invocation reached the target subsystem

         InvocationRequest i =
            RemotingTestSubsystemService.getNextInvocationFromServer(subsystemService, 2000);


         // send a ton of invocations
         int COUNT = 200;

         for(int i = 0; i < COUNT; i++)
         {
            client.invokeOneway("ignore");
         }

         // wait a bit until all invocations are flushed from the server-side pool
         Thread.sleep(5000);
      }

      DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler();
      client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI));
      assertEquals(1, invocationHandler.callbackHandlers.size());
      log.info("client added callback handler");
     
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      Thread.sleep(500);
      assertEquals(3, callbackHandler.callbackCounter);
     

      client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI));
      assertEquals(1, invocationHandler.callbackHandlers.size());
      log.info("client added callback handler");
     
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      Thread.sleep(500);
      assertEquals(3, callbackHandler.callbackCounter);
     
      Iterator it = invocationHandler.callbackHandlers.iterator();

      assertEquals(1, invocationHandler.callbackHandlers.size());
      log.info("client added callback handler");
     
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      Thread.sleep(500);
      assertEquals(3, callbackHandler.callbackCounter);
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next();

      client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI1));
      client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI2));
      assertEquals(2, invocationHandler.callbackHandlers.size());
      log.info("client added callback handlers");
     
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      Thread.sleep(500);
      assertEquals(2, callbackHandler.callbackCounter);
     
      Iterator it = invocationHandler.callbackHandlers.iterator();

      client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI2));
      assertEquals(2, invocationHandler.callbackHandlers.size());
      log.info("client added callback handlers");
     
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      Thread.sleep(500);
      assertEquals(2, callbackHandler.callbackCounter);
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next();

      assertEquals(3, handler.startedCount);
     
      // This invocation should run in the ServerThread, and will not return
      // until after a response is received.
      log.info("making 4th oneway invocation");
      client.invokeOneway(SLOW + "4", null, false);
      log.info("made 4th oneway invocation");
      log.info("wait: " + (System.currentTimeMillis() - start));
      assertTrue((System.currentTimeMillis() - start >= 8000));
     
      // By the time the 4th oneway invocation returns, the 3rd oneway invocation

     
      long start = System.currentTimeMillis();
     
      // This invocation should run in pooled thread 1.
      log.info("making 1st oneway invocation");
      client.invokeOneway(SLOW + "1", null, false);
      poolCounter++;
     
      // Wait for the connection to return to the pool.
      Thread.sleep(500);
     

      // Wait for the connection to return to the pool.
      Thread.sleep(500);
     
      // This invocation should run in pooled thread 2.
      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, false);
     
      // Wait for the connection to return to the pool.
      Thread.sleep(500);
     
      // This invocation should use the pooled connection and go into the queue.

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.