Package org.jboss.remoting

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


     
      long start = System.currentTimeMillis();
     
      // This invocation should run in pooled thread 1.
      log.info("making 1st oneway invocation");
      client.invokeOneway(SLOW + "1", null, true);
      poolCounter++;
     
      // This invocation should run in pooled thread 2.
      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, true);


      client.invokeOneway(SLOW + "1", null, true);
      poolCounter++;
     
      // This invocation should run in pooled thread 2.
      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, true);
     
      // This invocation should go into the queue.
      log.info("making 3rd oneway invocation");
      client.invokeOneway(SLOW + "3", null, true);
      assertTrue((System.currentTimeMillis() - start < 1000));

      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, true);
     
      // This invocation should go into the queue.
      log.info("making 3rd oneway invocation");
      client.invokeOneway(SLOW + "3", null, true);
      assertTrue((System.currentTimeMillis() - start < 1000));
      Thread.sleep(2000);
      log.info("handler.count: " + handler.startedCount);
      assertEquals(3, handler.startedCount);
     

     
      // This invocation should run in the current thread, and will not return
      // until after a response is received.
      start = System.currentTimeMillis();
      log.info("making 4th oneway invocation");
      client.invokeOneway(SLOW + "4", null, true);
      log.info("made 4th oneway invocation");
      log.info("wait: " + (System.currentTimeMillis() - start));
      assertTrue((System.currentTimeMillis() - start >= 5000));
     
      Thread.sleep(12000);

      // find a pooled connection and connect to a ServerThread busy with the
      // previous invocation.
     
      // Will execute in first thread pool thread.
      log.info("making 1st oneway invocation");
      client.invokeOneway(SLOW + "1", null, true);
      poolCounter++;
     
      // Will execute in first or second thread pool thread.
      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, true);

      client.invokeOneway(SLOW + "1", null, true);
      poolCounter++;
     
      // Will execute in first or second thread pool thread.
      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, true);
     
      // Could execute in a thread pool thread or go on the queue.
      log.info("making 3rd oneway invocation");
      client.invokeOneway(SLOW + "3", null, true);
      assertTrue((System.currentTimeMillis() - start < 1000));

      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, true);
     
      // Could execute in a thread pool thread or go on the queue.
      log.info("making 3rd oneway invocation");
      client.invokeOneway(SLOW + "3", null, true);
      assertTrue((System.currentTimeMillis() - start < 1000));
     
      // Could execute in a thread pool thread, go on the queue, or execute
      // in the main thread.
      log.info("making 4th oneway invocation");

      assertTrue((System.currentTimeMillis() - start < 1000));
     
      // Could execute in a thread pool thread, go on the queue, or execute
      // in the main thread.
      log.info("making 4th oneway invocation");
      client.invokeOneway(SLOW + "4", null, true);
      log.info("made 4th oneway invocation");
      log.info("wait: " + (System.currentTimeMillis() - start));
      assertTrue((System.currentTimeMillis() - start < 1000));
     
      // In the worst case, the four invocations could take as much as 15 seconds

     
      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 connection to return to pool.
      Thread.sleep(500);
     

      // Wait for connection to return to 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 connection to return to 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.