Search in sources :

Example 1 with MatcherRegisterFailedEvent

use of won.bot.framework.eventbot.event.impl.matcher.MatcherRegisterFailedEvent in project webofneeds by researchstudio-sat.

the class RegisterMatcherAction method doRun.

@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
    final Iterator wonNodeUriIterator = getEventListenerContext().getMatcherNodeURISource().getNodeURIIterator();
    while (wonNodeUriIterator.hasNext()) {
        URI wonNodeUri = (URI) wonNodeUriIterator.next();
        try {
            if (!registeredNodes.contains(wonNodeUri)) {
                logger.debug("registering matcher on won node {}", wonNodeUri);
                EventBotActionUtils.rememberInNodeListIfNamePresent(getEventListenerContext(), wonNodeUri);
                getEventListenerContext().getMatcherProtocolMatcherService().register(wonNodeUri);
                registeredNodes.add(wonNodeUri);
                logger.info("matcher registered on won node {}", wonNodeUri);
            }
        } catch (Exception e) {
            logger.warn("Error registering matcher at won node {}. Try again later ... Exception was {}", wonNodeUri, e);
            getEventListenerContext().getEventBus().publish(new MatcherRegisterFailedEvent(wonNodeUri));
        }
    }
}
Also used : Iterator(java.util.Iterator) MatcherRegisterFailedEvent(won.bot.framework.eventbot.event.impl.matcher.MatcherRegisterFailedEvent) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 Iterator (java.util.Iterator)1 MatcherRegisterFailedEvent (won.bot.framework.eventbot.event.impl.matcher.MatcherRegisterFailedEvent)1