Search in sources :

Example 11 with ManagementStrategy

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

the class EventHelper method notifyExchangeFailureHandling.

public static void notifyExchangeFailureHandling(CamelContext context, Exchange exchange, Processor failureHandler, boolean deadLetterChannel, String deadLetterUri) {
    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.createExchangeFailureHandlingEvent(exchange, failureHandler, deadLetterChannel, deadLetterUri);
        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 12 with ManagementStrategy

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

the class EventHelper method notifyExchangeDone.

public static void notifyExchangeDone(CamelContext context, Exchange exchange) {
    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.isIgnoreExchangeCompletedEvent()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createExchangeCompletedEvent(exchange);
        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 13 with ManagementStrategy

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

the class EventHelper method notifyCamelContextResumed.

public static void notifyCamelContextResumed(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.createCamelContextResumedEvent(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 14 with ManagementStrategy

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

the class EventHelper method notifyCamelContextResumeFailed.

public static void notifyCamelContextResumeFailed(CamelContext context, 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.isIgnoreCamelContextEvents()) {
            continue;
        }
        EventFactory factory = management.getEventFactory();
        if (factory == null) {
            return;
        }
        EventObject event = factory.createCamelContextResumeFailureEvent(context, 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 15 with ManagementStrategy

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

the class JettyHttpComponent method getMbContainer.

public synchronized MBeanContainer getMbContainer() {
    // If null, provide the default implementation.
    if (mbContainer == null) {
        MBeanServer mbs = null;
        final ManagementStrategy mStrategy = this.getCamelContext().getManagementStrategy();
        final ManagementAgent mAgent = mStrategy.getManagementAgent();
        if (mAgent != null) {
            mbs = mAgent.getMBeanServer();
        }
        if (mbs != null) {
            mbContainer = new MBeanContainer(mbs);
            startMbContainer();
        } else {
            LOG.warn("JMX disabled in CamelContext. Jetty JMX extensions will remain disabled.");
        }
    }
    return this.mbContainer;
}
Also used : ManagementAgent(org.apache.camel.spi.ManagementAgent) ManagementStrategy(org.apache.camel.spi.ManagementStrategy) MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) MBeanServer(javax.management.MBeanServer)

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