Search in sources :

Example 1 with DeliveryResponseEvent

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());
    }
}
Also used : SuccessResponseEvent(won.bot.framework.eventbot.event.impl.wonmessage.SuccessResponseEvent) MessageFromOtherAtomEvent(won.bot.framework.eventbot.event.impl.wonmessage.MessageFromOtherAtomEvent) Stopwatch(org.javasimon.Stopwatch) CrawlDoneEvent(won.bot.framework.eventbot.event.impl.monitor.CrawlDoneEvent) MessageSpecificEvent(won.bot.framework.eventbot.event.impl.wonmessage.MessageSpecificEvent) URI(java.net.URI) DeliveryResponseEvent(won.bot.framework.eventbot.event.impl.wonmessage.DeliveryResponseEvent) CrawlReadyEvent(won.bot.framework.eventbot.event.impl.monitor.CrawlReadyEvent) MessageDispatchedEvent(won.bot.framework.eventbot.event.impl.monitor.MessageDispatchedEvent) MessageDispatchStartedEvent(won.bot.framework.eventbot.event.impl.monitor.MessageDispatchStartedEvent) WonMessage(won.protocol.message.WonMessage) Split(org.javasimon.Split) FailureResponseEvent(won.bot.framework.eventbot.event.impl.wonmessage.FailureResponseEvent)

Aggregations

URI (java.net.URI)1 Split (org.javasimon.Split)1 Stopwatch (org.javasimon.Stopwatch)1 CrawlDoneEvent (won.bot.framework.eventbot.event.impl.monitor.CrawlDoneEvent)1 CrawlReadyEvent (won.bot.framework.eventbot.event.impl.monitor.CrawlReadyEvent)1 MessageDispatchStartedEvent (won.bot.framework.eventbot.event.impl.monitor.MessageDispatchStartedEvent)1 MessageDispatchedEvent (won.bot.framework.eventbot.event.impl.monitor.MessageDispatchedEvent)1 DeliveryResponseEvent (won.bot.framework.eventbot.event.impl.wonmessage.DeliveryResponseEvent)1 FailureResponseEvent (won.bot.framework.eventbot.event.impl.wonmessage.FailureResponseEvent)1 MessageFromOtherAtomEvent (won.bot.framework.eventbot.event.impl.wonmessage.MessageFromOtherAtomEvent)1 MessageSpecificEvent (won.bot.framework.eventbot.event.impl.wonmessage.MessageSpecificEvent)1 SuccessResponseEvent (won.bot.framework.eventbot.event.impl.wonmessage.SuccessResponseEvent)1 WonMessage (won.protocol.message.WonMessage)1