Package akka.event

Examples of akka.event.LoggingAdapter


   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    ActorSystem system = ActorSystem.create("faultTolerance");

    LoggingAdapter log = Logging.getLogger(system, system);

    Integer originalValue = Integer.valueOf(0);

    ActorRef supervisor = system.actorOf(new Props(SupervisorActor2.class),
        "supervisor");

    log.info("Sending value 8, no exceptions should be thrown! ");
    supervisor.tell(Integer.valueOf(8));

    Integer result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert result.equals(Integer.valueOf(8));

    log.info("Sending value -8, ArithmeticException should be thrown! Our Supervisor strategy says resume !");
    supervisor.tell(Integer.valueOf(-8));

    result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert result.equals(Integer.valueOf(8));

    log.info("Sending value null, NullPointerException should be thrown! Our Supervisor strategy says restart !");
    supervisor.tell(null);

    result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert originalValue.equals(result);

    log.info("Sending value \"String\", IllegalArgumentException should be thrown! Our Supervisor strategy says Stop !");

    supervisor.tell(String.valueOf("Do Something"));

    log.info("Worker Actor shutdown !");
    system.shutdown();

  }
View Full Code Here


   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    ActorSystem system = ActorSystem.create("faultTolerance");

    LoggingAdapter log = Logging.getLogger(system, system);

    Integer originalValue = Integer.valueOf(0);

    ActorRef supervisor = system.actorOf(new Props(SupervisorActor.class),
        "supervisor");

    log.info("Sending value 8, no exceptions should be thrown! ");
    supervisor.tell(Integer.valueOf(8));

    Integer result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert result.equals(Integer.valueOf(8));

    log.info("Sending value -8, ArithmeticException should be thrown! Our Supervisor strategy says resume !");
    supervisor.tell(Integer.valueOf(-8));

    result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert result.equals(Integer.valueOf(8));

    log.info("Sending value null, NullPointerException should be thrown! Our Supervisor strategy says restart !");
    supervisor.tell(null);

    result = (Integer) Await.result(
        Patterns.ask(supervisor, new Result(), 5000),
        Duration.create(5000, TimeUnit.MILLISECONDS));

    log.info("Value Received-> {}", result);
    assert originalValue.equals(result);

    log.info("Sending value \"String\", IllegalArgumentException should be thrown! Our Supervisor strategy says Stop !");

    supervisor.tell(String.valueOf("Do Something"));

    log.info("Worker Actor shutdown !");
    system.shutdown();
  }
View Full Code Here

    assertSame(Option.none(), Option.none());
  }

  @Test
  public void mustBeAbleToGetNoLogging() {
      LoggingAdapter a = NoLogging.getInstance();
      assertNotNull(a);
  }
View Full Code Here

TOP

Related Classes of akka.event.LoggingAdapter

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.