예제 #1
0
  @Test
  public void testTcpWorkerDupAndCancel() {
    ActorRef asyncWorker = null;
    logger.info("IN testTcpWorkerDupAndCancel");
    try {

      // Start new job

      int actorMaxOperationTimeoutSec = 15;
      asyncWorker =
          ActorConfig.createAndGetActorSystem()
              .actorOf(
                  Props.create(
                      TcpWorker.class, actorMaxOperationTimeoutSec, getTcpMetaSample(), LOCALHOST));

      final FiniteDuration duration = Duration.create(20, TimeUnit.SECONDS);
      Future<Object> future =
          Patterns.ask(asyncWorker, RequestWorkerMsgType.PROCESS_REQUEST, new Timeout(duration));
      // test dup
      asyncWorker.tell(RequestWorkerMsgType.PROCESS_REQUEST, asyncWorker);

      // test cancel
      asyncWorker.tell(RequestWorkerMsgType.CANCEL, asyncWorker);
      ResponseOnSingeRequest response = (ResponseOnSingeRequest) Await.result(future, duration);

      logger.info("\nWorker response:" + response.toString());

    } catch (Throwable ex) {

      logger.error("Exception in test : " + ex);
    }
  } // end func
예제 #2
0
  @Test
  public void testTcpWorkerBadMsgType() {

    logger.info("IN testTcpWorkerBadMsgType");
    ActorRef asyncWorker = null;
    try {
      // made a timeout
      int actorMaxOperationTimeoutSec = 15;
      asyncWorker =
          ActorConfig.createAndGetActorSystem()
              .actorOf(
                  Props.create(
                      TcpWorker.class, actorMaxOperationTimeoutSec, getTcpMetaSample(), LOCALHOST));

      final FiniteDuration duration = Duration.create(20, TimeUnit.SECONDS);
      Future<Object> future = Patterns.ask(asyncWorker, new Integer(0), new Timeout(duration));
      ResponseOnSingeRequest response = (ResponseOnSingeRequest) Await.result(future, duration);

      logger.info("\nWorker response:" + response.toString());
    } catch (Throwable ex) {

      logger.error("Exception in test : " + ex);
    }
  } // end func