Example #1
0
 @Override
 protected Void doRun() throws InterruptedException, SuspendExecution {
   final HelloMessage message = receive();
   System.out.println("Message received '" + message + '\'');
   RequestReplyHelper.reply(message, 1);
   return null;
 }
Example #2
0
  public boolean addHandler(EventHandler<Event> handler)
      throws SuspendExecution, InterruptedException {
    if (isInActor()) return GenEventActor.<Event>currentGenEvent().addHandler(handler);

    final GenResponseMessage res =
        call(
            this, new GenEventActor.HandlerMessage(RequestReplyHelper.from(), null, handler, true));
    return ((GenValueResponseMessage<Boolean>) res).getValue();
  }
Example #3
0
  public static void main(String[] args) throws Exception {
    final Properties props = new Properties();
    props.setProperty("galaxy.nodeId", Integer.toString(nodeId));
    props.setProperty("galaxy.port", Integer.toString(7050 + nodeId));
    props.setProperty("galaxy.slave_port", Integer.toString(8050 + nodeId));

    final Grid grid = Grid.getInstance(null, props);
    grid.goOnline();

    final MyActor actor = new MyActor();
    actor.spawnThread();
    actor.register(ACTOR_NAME);

    final ActorRef<HelloMessage> ref = ActorRegistry.getActor(ACTOR_NAME);

    try {
      RequestReplyHelper.call(ref, new HelloMessage());
    } catch (Throwable e) {
      log.error("====>", e);
    }

    grid.cluster().goOffline();
  }