Package akka.util

Examples of akka.util.Timeout


   
    //wait for child actor to get restarted
    Thread.sleep(500);
   
    // Invoke the method and wait for result
    Timeout timeout = new Timeout(Duration.parse("5 seconds"));
      Future<Object> future = Patterns.ask(calActor, Integer.valueOf(10), timeout);
      Integer result = (Integer) Await.result(future, timeout.duration());
   
    System.out.println("Result from child actor->" + result);

    //wait before shutting down the system
    Thread.sleep(500);
View Full Code Here


        System.out.println("*** SENDING OK");
    }

    private void retrieveMessages(ActorSystem system) throws Exception {
        ActorRef service = getService(system);
        Timeout timeout = new Timeout(Duration.create(2, TimeUnit.SECONDS));
        Future<Object> fBets = Patterns.ask(service, new RetrieveBets(), timeout);
        List<Bet> bets = (List<Bet>) Await.result(fBets, timeout.duration());
        assert bets.size() == 200;
        System.out.println("*** TESTING OK");
    }
View Full Code Here

  @Override
  protected CommitMessage<?> activate(ActivationMessage message) {

    /** The timeout for collecting the deactivation commits (which is slightly shorter than the timeout
     * for this event definition, to be able to handle the timeout exception here) */
    Timeout deactivationTimeout = new Timeout(Duration.create((long) (timeoutInSeconds * 0.95), "seconds"));
   
    Future<Iterable<Object>> futureSequence = new NodeUtils().deactivateNodes(otherActorReferences, message.getProcessInstanceId(), deactivationTimeout, this.getSender(), this.getSelf());

      // send commit to underlying event
    return createCommitMessage(futureSequence, message.getProcessInstanceId());
View Full Code Here

   * @param timeoutInSeconds the timeout in seconds
   * @param eventDefinitionParameter the event definition parameter to instantiate the EventDefinition actor
   */
  public static void callEventDefinitionActor(ActorRef eventDefinitionActor, String uniqueFlowNodeId, Message message, long timeoutInSeconds, EventDefinitionParameter eventDefinitionParameter) {
   
    final Timeout eventDefinitionTimeout = new Timeout(Duration.create(timeoutInSeconds, "seconds"));
   
    // create an akka future which holds the commit message (if any) of the eventDefinitionActor
    Future<Object> future = Patterns.ask(eventDefinitionActor, message, eventDefinitionTimeout);

    try {
      // make a synchronous ('Await.result') request ('Patterns.ask') to the event definition actor
      Await.result(future, eventDefinitionTimeout.duration());
    } catch (java.util.concurrent.TimeoutException timeout) {
      LOG.error(String.format("Unhandled timeout while processing %s at EventDefintition:%s. Timeout was set to %s",
          message.getClass().getSimpleName(), eventDefinitionActor, eventDefinitionTimeout.duration()));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

      public UntypedActor create() {
        return new ActorLevel1(iData, numberOfWorkers);
      }
    }), "ActorLevel1-" + System.currentTimeMillis());
   
    Timeout timeout = new Timeout(Duration.create(numberOfSecondsTimeout, "seconds"));
    Future<Object> future = Patterns.ask(actorLevel1, new Message_Runner_to_AL1(parameters, functionToApply), timeout);
    List<Object> results = new ArrayList<Object>();
    try {
      results = (List<Object>) Await.result(future, timeout.duration());
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return results;
View Full Code Here

    ActorSystem system = ActorSystem.create("ClusterSystem", config);

    final ActorRef frontend = system.actorOf(
        Props.create(TransformationFrontend.class), "frontend");
    final FiniteDuration interval = Duration.create(2, TimeUnit.SECONDS);
    final Timeout timeout = new Timeout(Duration.create(5, TimeUnit.SECONDS));
    final ExecutionContext ec = system.dispatcher();
    final AtomicInteger counter = new AtomicInteger();
    system.scheduler().schedule(interval, interval, new Runnable() {
      public void run() {
        ask(frontend,
View Full Code Here

        ActorRef actorA = system.actorOf(Props.create(MyUntypedActor.class));
        ActorRef actorB = system.actorOf(Props.create(MyUntypedActor.class));
        ActorRef actorC = getRef();

        //#ask-pipe
        final Timeout t = new Timeout(Duration.create(5, TimeUnit.SECONDS));

        final ArrayList<Future<Object>> futures = new ArrayList<Future<Object>>();
        futures.add(ask(actorA, "request", 1000)); // using 1000ms timeout
        futures.add(ask(actorB, "another request", t)); // using timeout from
                                                        // above
View Full Code Here

        new Add(new Const(1), new Const(1))
      )
    );

    FiniteDuration duration = Duration.create(1, TimeUnit.SECONDS);
    Integer result = Await.result(ask(calculatorService, task, new Timeout(duration)).mapTo(classTag(Integer.class)), duration);
    System.out.println("Got result: " + result);

    Await.ready(system.terminate(), Duration.Inf());
  }
View Full Code Here

  @Test
  public void useBlockingFromActor() throws Exception {
    ActorRef actor = system.actorOf(Props.create(MyActor.class));
    String msg = "hello";
    //#ask-blocking
    Timeout timeout = new Timeout(Duration.create(5, "seconds"));
    Future<Object> future = Patterns.ask(actor, msg, timeout);
    String result = (String) Await.result(future, timeout.duration());
    //#ask-blocking
    //#pipe-to
    akka.pattern.Patterns.pipe(future, system.dispatcher()).to(actor);
    //#pipe-to
    assertEquals("HELLO", result);
View Full Code Here

    ActorSystem system = ActorSystem.create("some-system");
    Props props = Props.create(MyConsumer.class);
    ActorRef producer = system.actorOf(props,"myproducer");
    Camel camel = CamelExtension.get(system);
    // get a future reference to the activation of the endpoint of the Consumer Actor
    Timeout timeout = new Timeout(Duration.create(10, SECONDS));
    Future<ActorRef> activationFuture = camel.activationFutureFor(producer,
      timeout, system.dispatcher());
    //#CamelActivation
    //#CamelDeactivation
    // ..
View Full Code Here

TOP

Related Classes of akka.util.Timeout

Copyright © 2018 www.massapicom. 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.