Search in sources :

Example 1 with ManagementStrategy

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

the class EventHelper method notifyCamelContextSuspending.

public static void notifyCamelContextSuspending(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.createCamelContextSuspendingEvent(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 2 with ManagementStrategy

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

the class EventHelper method notifyRouteStarted.

public static void notifyRouteStarted(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.createRouteStartedEvent(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 3 with ManagementStrategy

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

the class EventHelper method notifyExchangeSending.

public static void notifyExchangeSending(CamelContext context, Exchange exchange, Endpoint endpoint) {
    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.createExchangeSendingEvent(exchange, endpoint);
        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 4 with ManagementStrategy

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

the class EventHelper method notifyRouteAdded.

public static void notifyRouteAdded(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.createRouteAddedEvent(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 5 with ManagementStrategy

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

the class EventHelper method notifyExchangeRedelivery.

public static void notifyExchangeRedelivery(CamelContext context, Exchange exchange, int attempt) {
    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.isIgnoreExchangeFailedEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeRedeliveryEvent(exchange, attempt);
        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

ManagementStrategy (org.apache.camel.spi.ManagementStrategy)33 EventNotifier (org.apache.camel.spi.EventNotifier)28 EventFactory (org.apache.camel.spi.EventFactory)27 EventObject (java.util.EventObject)25 DefaultManagementStrategy (org.apache.camel.management.DefaultManagementStrategy)5 DefaultManagementLifecycleStrategy (org.apache.camel.management.DefaultManagementLifecycleStrategy)3 ManagedManagementStrategy (org.apache.camel.management.ManagedManagementStrategy)3 HandleFault (org.apache.camel.processor.interceptor.HandleFault)3 LifecycleStrategy (org.apache.camel.spi.LifecycleStrategy)3 ShutdownStrategy (org.apache.camel.spi.ShutdownStrategy)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TypeConverters (org.apache.camel.TypeConverters)2 DefaultManagementAgent (org.apache.camel.management.DefaultManagementAgent)2 BacklogTracer (org.apache.camel.processor.interceptor.BacklogTracer)2 TraceFormatter (org.apache.camel.processor.interceptor.TraceFormatter)2 Tracer (org.apache.camel.processor.interceptor.Tracer)2 AsyncProcessorAwaitManager (org.apache.camel.spi.AsyncProcessorAwaitManager)2 EndpointStrategy (org.apache.camel.spi.EndpointStrategy)2 InflightRepository (org.apache.camel.spi.InflightRepository)2