public final class CdiEventEndpoint<T>
extends org.apache.camel.impl.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);
}
Modifier and Type | Method and Description |
---|---|
org.apache.camel.Consumer |
createConsumer(org.apache.camel.Processor processor) |
org.apache.camel.Producer |
createProducer() |
boolean |
isSingleton() |
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 org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor)
public org.apache.camel.Producer createProducer() throws IllegalAccessException
IllegalAccessException
public boolean isSingleton()
Apache Camel