public final class CdiEventEndpoint<T> extends DefaultEndpoint
Endpoint
that bridges the CDI events facility with Camel routes so that CDI events
can be seamlessly observed / consumed (respectively produced / fired) from Camel consumers (respectively by Camel producers).
The CdiEventEndpoint<T>
bean can be used to observe / consume CDI events whose event type is T
, for example:
@Inject
CdiEventEndpoint <String > cdiEventEndpoint;
from(cdiEventEndpoint).log("CDI event received: ${body}");
Conversely, the CdiEventEndpoint<T>
bean can be used to produce / fire CDI events whose event type is T
, for example:
@Inject
CdiEventEndpoint <String > cdiEventEndpoint;
from("direct:event").to(cdiEventEndpoint).log("CDI event sent: ${body}");
The type variable T
, respectively the qualifiers, of a particular CdiEventEndpoint<T>
injection point
are automatically translated into the parameterized event type, respectively into the event qualifiers, e.g.:
@Inject
@FooQualifier
CdiEventEndpoint <List <String > > cdiEventEndpoint;
from("direct:event").to(cdiEventEndpoint);
void observeCdiEvents( @Observes @FooQualifier List <String > event) {
logger.info("CDI event: {}", event);
}
When multiple Camel contexts exist in the CDI container, the @ContextName
qualifier can be used
to qualify the CdiEventEndpoint<T>
injection points, e.g.:
@Inject
@ContextName("foo")
CdiEventEndpoint <List <String > > cdiEventEndpoint;
// Only observe / consume events having the @ContextName("foo") qualifier
from(cdiEventEndpoint).log("Camel context 'foo' > CDI event received: ${body}");
// Produce / fire events with the @ContextName("foo") qualifier
from("...").to(cdiEventEndpoint);
void observeCdiEvents( @Observes @ContextName("foo") List <String > event) {
logger.info("Camel context 'foo' > CDI event: {}", event);
}
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Modifier and Type | Method and Description |
---|---|
Consumer |
createConsumer(Processor processor)
Creates a new Event
Driven Consumer which consumes messages from the endpoint using the
given processor
|
Producer |
createProducer()
Creates a new producer which is used send messages into the endpoint
|
boolean |
isSingleton()
Whether this class supports being singleton or not.
|
configureConsumer, configurePollingConsumer, configureProperties, createEndpointConfiguration, createEndpointUri, createExchange, createExchange, createExchange, createPollingConsumer, doStart, doStop, equals, getCamelContext, getComponent, getConsumerProperties, getEndpointConfiguration, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isBridgeErrorHandler, isLenientProperties, isPollingConsumerBlockWhenFull, isSynchronous, setBridgeErrorHandler, setCamelContext, setConsumerProperties, setEndpointConfiguration, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public Consumer createConsumer(Processor processor)
Endpoint
processor
- the given processorpublic Producer createProducer()
Endpoint
public boolean isSingleton()
IsSingleton
Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.