@Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
    Object msg = e.getMessage();
    if (msg == null) return;

    // end of batch?
    if (msg == ControlMessage.EOB_MESSAGE) {
      Channel channel = ctx.getChannel();
      LOG.debug("Send back response ...");
      if (failure_count.get() == 0) channel.write(ControlMessage.OK_RESPONSE);
      else channel.write(ControlMessage.FAILURE_RESPONSE);
      return;
    }

    // enqueue the received message for processing
    try {
      server.enqueue((TaskMessage) msg);
    } catch (InterruptedException e1) {
      LOG.info("failed to enqueue a request message", e);
      failure_count.incrementAndGet();
    }
  }
Beispiel #2
0
 public void received(Object message, String remote, Channel channel) throws InterruptedException {
   List<TaskMessage> msgs = (List<TaskMessage>) message;
   enqueue(msgs, remote);
 }