Package org.jboss.remoting

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


         makeExceptionInvocation(remotingClient, metadata);

         remotingClient.invokeOneway("Do something", metadata, true);

         remotingClient.invokeOneway("Do something", metadata, false);
      }
      catch (Throwable throwable)
      {
         throw new Exception(throwable);
      }


      client.connect();
      log.info("client is connected");
      SampleCallbackHandler callbackHandler = new SampleCallbackHandler();
      client.addListener(callbackHandler, null, null, true);
      log.info("client added callback handler");
      client.invokeOneway(AsynchCallbackTestServerRoot.SYNCHRONOUS_TEST);
      Thread.sleep(1000);
      // Should still be waiting on client.
      Boolean done = (Boolean) client.invoke(AsynchCallbackTestServerRoot.GET_STATUS);
      log.info("done 1: " + done);
      assertFalse(done.booleanValue());

      client.connect();
      log.info("client is connected");
      SampleCallbackHandler callbackHandler = new SampleCallbackHandler();
      client.addListener(callbackHandler, null, null, true);
      log.info("client added callback handler");
      client.invokeOneway(AsynchCallbackTestServerRoot.ASYNCHRONOUS_CLIENT_SIDE_TEST);
      Thread.sleep(500);
      // Should have returned.
      Boolean done = (Boolean) client.invoke(AsynchCallbackTestServerRoot.GET_STATUS);
      assertTrue(done.booleanValue());
      assertTrue(callbackHandler.receivedCallback);

      client.connect();
      log.info("client is connected");
      SampleCallbackHandler callbackHandler = new SampleCallbackHandler();
      client.addListener(callbackHandler, null, null, true);
      log.info("client added callback handler");
      client.invokeOneway(AsynchCallbackTestServerRoot.ASYNCHRONOUS_SERVER_SIDE_TEST);
      Thread.sleep(500);
      // Should have returned.
      Boolean done = (Boolean) client.invoke(AsynchCallbackTestServerRoot.GET_STATUS);
      assertTrue(done.booleanValue());
      assertTrue(callbackHandler.receivedCallback);

         clientConfig.put(Client.MAX_NUM_ONEWAY_THREADS, "7");
         clientConfig.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "9");
         Client client = new Client(locator, clientConfig);
         client.connect();
        
         client.invokeOneway(FAST, null, true);
         client.invokeOneway(FAST, null, false);
         poolCounter += 2;
         Thread.sleep(1000);
         assertEquals(2, handler.startedCount);
        

         clientConfig.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "9");
         Client client = new Client(locator, clientConfig);
         client.connect();
        
         client.invokeOneway(FAST, null, true);
         client.invokeOneway(FAST, null, false);
         poolCounter += 2;
         Thread.sleep(1000);
         assertEquals(2, handler.startedCount);
        
         Field field = ServerInvoker.class.getDeclaredField("onewayThreadPool");

     
      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);

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.