/** * Sends a reply to a message. The reply will propagate back to the original sender, prefering the same route as it * used to reach the detination. * * @param reply The reply, created from the message this is a reply to. */ public void reply(Reply reply) { ReplyHandler handler = reply.popHandler(); handler.handleReply(reply); }
@Override public void handleReply(Reply reply) { reply.popHandler().handleReply(reply); }
@Override public void handleReply(Reply reply) { reply.popHandler().handleReply(reply); }
/** * Forwards a routable to the next hop in its route. This method will never block. * @param routable the routable to forward. */ public void forward(Routable routable) { if (routable instanceof Reply) { Reply reply = (Reply)routable; ReplyHandler handler = reply.popHandler(); handler.handleReply(reply); } else { routable.pushHandler(this); mbus.handleMessage((Message)routable); } }
@Override public void handleReply(Reply reply) { if (destroyed.get()) { reply.discard(); return; } if (doAccounting()) { synchronized (this) { --pendingCount; pendingSize -= (Integer)reply.getContext(); } } deliverReply(reply, reply.popHandler()); }
sequencedSend(msg); ReplyHandler handler = reply.popHandler(); handler.handleReply(reply);
/** * <p>Constructs and schedules a Reply containing an error to the handler of the given Message.</p> * * @param msg The message to reply to. * @param errCode The code of the error to set. * @param errMsg The message of the error to set. */ private void deliverError(Message msg, int errCode, String errMsg) { Reply reply = new EmptyReply(); reply.swapState(msg); reply.addError(new Error(errCode, errMsg)); deliverReply(reply, reply.popHandler()); }
@Override public void handleReply(final Reply reply) { reply.getTrace().trace(6, "Reply received by MbusClient."); final ResponseHandler handler = (ResponseHandler)reply.getContext(); reply.popHandler(); // restore user context try { handler.handleResponse(new MbusResponse(StatusCodes.fromMbusReply(reply), reply)) .close(IgnoredCompletionHandler.INSTANCE); } catch (final Exception e) { log.log(LogLevel.WARNING, "Ignoring exception thrown by ResponseHandler.", e); } }
@Override public void handleReply(Reply reply) { if (destroyed.get()) { reply.discard(); return; } boolean done; synchronized (lock) { --pendingCount; if (throttlePolicy != null) { throttlePolicy.processReply(reply); } done = (closed && pendingCount == 0); sendBlockedMessages(); } if (reply.getTrace().shouldTrace(TraceLevel.COMPONENT)) { reply.getTrace().trace(TraceLevel.COMPONENT, "Source session received reply. " + pendingCount + " message(s) now pending."); } ReplyHandler handler = reply.popHandler(); handler.handleReply(reply); if (done) { this.done.countDown(); } }
private boolean sendMessage(final MbusRequest request) { Error error; final Long millis = request.timeRemaining(TimeUnit.MILLISECONDS); if (millis != null && millis <= 0) { error = new Error(ErrorCode.TIMEOUT, request.getTimeout(TimeUnit.MILLISECONDS) + " millis"); } else if (request.isCancelled()) { error = new Error(ErrorCode.APP_FATAL_ERROR, "request cancelled"); } else { try { error = session.sendMessage(request.getMessage()).getError(); } catch (final Exception e) { error = new Error(ErrorCode.FATAL_ERROR, e.toString()); } } if (error == null) { return true; } if (error.isFatal()) { final Reply reply = new EmptyReply(); reply.swapState(request.getMessage()); reply.addError(error); reply.popHandler().handleReply(reply); return true; } return false; }
ReplyHandler handler = reply.popHandler(); handler.handleReply(reply);