private void dispatchResponse(int status) { ResponseDispatch.newInstance(new MbusResponse(status, requestMsg.createReply())).dispatch(this); }
public void handleMessage(Message message) { Reply reply = ((DocumentMessage)message).createReply(); message.swapState(reply); params.getDataHandler().onMessage(message, new AckToken(reply)); }
private MessageHandler createMessageHandler() { return (message) -> { try { taskExecutor.submitTask(new HandleMessageTask(message)); } catch (RejectedExecutionException e) { Reply reply = ((DocumentMessage)message).createReply(); message.swapState(reply); reply.addError(new Error( DocumentProtocol.ERROR_ABORTED, "Visitor session has been aborted")); receiver.reply(reply); } }; }
@Override public void processingFailed(ErrorCode errorCode, String errorMsg) { MbusResponse response = new MbusResponse(errorCode.getDiscStatus(), requestMsg.createReply()); response.getReply().addError(new com.yahoo.messagebus.Error(errorCode.getDocumentProtocolStatus(), errorMsg)); ResponseDispatch.newInstance(response).dispatch(this); }
private void handleDocumentMessage(DocumentMessage msg) { Reply reply = msg.createReply(); msg.swapState(reply); if (params.getLocalDataHandler() == null) { log.log(LogLevel.ERROR, sessionName + ": Got visitor data back to client with no local data destination."); reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "Visitor data with no local data destination")); receiver.reply(reply); return; } try { params.getLocalDataHandler().onMessage(msg, new AckToken(reply)); } catch (Exception e) { handleMessageProcessingException(reply, e, "DocumentMessage"); // Immediately reply since we cannot count on AckToken being registered receiver.reply(reply); } }