use of won.bot.framework.eventbot.event.impl.wonmessage.DeliveryResponseEvent in project webofneeds by researchstudio-sat.
the class MessageLifecycleMonitoringAction method doRun.
@Override
protected void doRun(final Event event, EventListener executingListener) throws Exception {
Stopwatch stopwatchB = SimonManager.getStopwatch("messageTripB");
Stopwatch stopwatchBC = SimonManager.getStopwatch("messageTripBC");
Stopwatch stopwatchBCD = SimonManager.getStopwatch("messageTripBCD");
Stopwatch stopwatchBCDE = SimonManager.getStopwatch("messageTripBCDE");
if (event instanceof MessageSpecificEvent) {
MessageSpecificEvent msgEvent = (MessageSpecificEvent) event;
URI msgURI = msgEvent.getMessageURI();
logger.debug("RECEIVED EVENT {} for uri {}", event, msgURI);
if (event instanceof MessageDispatchStartedEvent) {
Split splitB = stopwatchB.start();
Split splitBC = stopwatchBC.start();
Split splitBCD = stopwatchBCD.start();
Split splitBCDE = stopwatchBCDE.start();
msgSplitsB.put(msgURI.toString(), splitB);
msgSplitsBC.put(msgURI.toString(), splitBC);
msgSplitsBCD.put(msgURI.toString(), splitBCD);
msgSplitsBCDE.put(msgURI.toString(), splitBCDE);
connectionMsgUris.put(msgURI, msgEvent.getAtomURI());
} else if (event instanceof MessageDispatchedEvent) {
msgSplitsB.get(msgURI.toString()).stop();
}
} else if (event instanceof SuccessResponseEvent || event instanceof FailureResponseEvent) {
DeliveryResponseEvent responseEvent = (DeliveryResponseEvent) event;
if (connectionMsgUris.containsKey(responseEvent.getOriginalMessageURI())) {
responseMsgUris.put(responseEvent.getMessage().getMessageURI(), responseEvent.getAtomURI());
}
if (msgSplitsBC.get(responseEvent.getOriginalMessageURI().toString()) != null) {
logger.debug("RECEIVED RESPONSE EVENT {} for uri {}", event, responseEvent.getOriginalMessageURI());
msgSplitsBC.get(responseEvent.getOriginalMessageURI().toString()).stop();
}
} else if (event instanceof MessageFromOtherAtomEvent) {
WonMessage msg = ((MessageFromOtherAtomEvent) event).getWonMessage();
msgSplitsBCD.get(msg.getMessageURI()).stop();
connectionMsgUris.put(msg.getMessageURI(), msg.getRecipientAtomURI());
} else if (event instanceof CrawlReadyEvent) {
reportMessageSizes(connectionMsgUris, "Connection Messages");
reportMessageSizes(responseMsgUris, "Delivery Responses");
getEventListenerContext().getEventBus().publish(new CrawlDoneEvent());
}
}
Aggregations