Search in sources :

Example 26 with EventNotifier

use of org.apache.camel.spi.EventNotifier in project camel by apache.

the class EventHelper method notifyCamelContextStarting.

public static void notifyCamelContextStarting(CamelContext context) {
    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }
    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }
    for (EventNotifier notifier : notifiers) {
        if (notifier.isIgnoreCamelContextEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createCamelContextStartingEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
Also used : ManagementStrategy(org.apache.camel.spi.ManagementStrategy) EventNotifier(org.apache.camel.spi.EventNotifier) EventFactory(org.apache.camel.spi.EventFactory) EventObject(java.util.EventObject)

Example 27 with EventNotifier

use of org.apache.camel.spi.EventNotifier in project camel by apache.

the class EventHelper method notifyServiceStartupFailure.

public static void notifyServiceStartupFailure(CamelContext context, Object service, Throwable cause) {
    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }
    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }
    for (EventNotifier notifier : notifiers) {
        if (notifier.isIgnoreServiceEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createServiceStartupFailureEvent(context, service, cause);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
Also used : ManagementStrategy(org.apache.camel.spi.ManagementStrategy) EventNotifier(org.apache.camel.spi.EventNotifier) EventFactory(org.apache.camel.spi.EventFactory) EventObject(java.util.EventObject)

Example 28 with EventNotifier

use of org.apache.camel.spi.EventNotifier in project camel by apache.

the class EventHelper method notifyExchangeSent.

public static void notifyExchangeSent(CamelContext context, Exchange exchange, Endpoint endpoint, long timeTaken) {
    if (exchange.getProperty(Exchange.NOTIFY_EVENT, false, Boolean.class)) {
        // do not generate events for an notify event
        return;
    }
    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }
    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }
    for (EventNotifier notifier : notifiers) {
        if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeSentEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeSentEvent(exchange, endpoint, timeTaken);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
Also used : ManagementStrategy(org.apache.camel.spi.ManagementStrategy) EventNotifier(org.apache.camel.spi.EventNotifier) EventFactory(org.apache.camel.spi.EventFactory) EventObject(java.util.EventObject)

Example 29 with EventNotifier

use of org.apache.camel.spi.EventNotifier in project camel by apache.

the class EventHelper method notifyRouteRemoved.

public static void notifyRouteRemoved(CamelContext context, Route route) {
    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }
    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }
    for (EventNotifier notifier : notifiers) {
        if (notifier.isIgnoreRouteEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createRouteRemovedEvent(route);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
Also used : ManagementStrategy(org.apache.camel.spi.ManagementStrategy) EventNotifier(org.apache.camel.spi.EventNotifier) EventFactory(org.apache.camel.spi.EventFactory) EventObject(java.util.EventObject)

Example 30 with EventNotifier

use of org.apache.camel.spi.EventNotifier in project camel by apache.

the class EventHelper method notifyCamelContextStopping.

public static void notifyCamelContextStopping(CamelContext context) {
    ManagementStrategy management = context.getManagementStrategy();
    if (management == null) {
        return;
    }
    List<EventNotifier> notifiers = management.getEventNotifiers();
    if (notifiers == null || notifiers.isEmpty()) {
        return;
    }
    for (EventNotifier notifier : notifiers) {
        if (notifier.isIgnoreCamelContextEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createCamelContextStoppingEvent(context);
        if (event == null) {
            return;
        }
        doNotifyEvent(notifier, event);
    }
}
Also used : ManagementStrategy(org.apache.camel.spi.ManagementStrategy) EventNotifier(org.apache.camel.spi.EventNotifier) EventFactory(org.apache.camel.spi.EventFactory) EventObject(java.util.EventObject)

Aggregations

EventNotifier (org.apache.camel.spi.EventNotifier)34 ManagementStrategy (org.apache.camel.spi.ManagementStrategy)28 EventFactory (org.apache.camel.spi.EventFactory)27 EventObject (java.util.EventObject)25 LifecycleStrategy (org.apache.camel.spi.LifecycleStrategy)4 BacklogTracer (org.apache.camel.processor.interceptor.BacklogTracer)3 HandleFault (org.apache.camel.processor.interceptor.HandleFault)3 Tracer (org.apache.camel.processor.interceptor.Tracer)3 AsyncProcessorAwaitManager (org.apache.camel.spi.AsyncProcessorAwaitManager)3 InflightRepository (org.apache.camel.spi.InflightRepository)3 RuntimeEndpointRegistry (org.apache.camel.spi.RuntimeEndpointRegistry)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 CamelContextAware (org.apache.camel.CamelContextAware)2 Consumer (org.apache.camel.Consumer)2 Service (org.apache.camel.Service)2 StatefulService (org.apache.camel.StatefulService)2 SuspendableService (org.apache.camel.SuspendableService)2