Interface Consumer
- All Superinterfaces:
AutoCloseable, EndpointAware, Service
- All Known Subinterfaces:
BatchConsumer, DynamicPollingConsumer, PollingConsumer
A service that receives messages from an
Endpoint and routes them as Exchanges through the Camel
processing pipeline.
Consumers are created by calling Endpoint.createConsumer(Processor) and participate in the Camel lifecycle as
Services. For endpoints that require a dedicated polling loop, see PollingConsumer; for endpoints
that deliver messages in batches, see BatchConsumer.
Important: Do not do any initialization in the constructor. Instead use
BaseService.doInit() or
BaseService.doStart().- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncreateExchange(boolean autoRelease) Creates anExchangethat was consumed.default @Nullable AsyncCallbackdefaultConsumerCallback(Exchange exchange, boolean autoRelease) The default callback to use with the consumer when calling the processor using asynchronous routing.The processor that will process theExchangethat was consumed.voidreleaseExchange(Exchange exchange, boolean autoRelease) Releases theExchangewhen its completed processing and no longer needed.Methods inherited from interface EndpointAware
getEndpoint
-
Method Details
-
getProcessor
-
createExchange
Creates anExchangethat was consumed. Important: If the auto release parameter is set to false then the consumer is responsible for calling thereleaseExchange(Exchange, boolean)when theExchangeis done being routed. This is for advanced consumers that need to have this control in their own hands. For normal use-cases then a consumer can use autoRelease true and then Camel will automatic release the exchange after routing.- Parameters:
autoRelease- whether to auto release the exchange when routing is complete viaUnitOfWork
-
releaseExchange
-
defaultConsumerCallback
The default callback to use with the consumer when calling the processor using asynchronous routing. This implementation will useExceptionHandlerto handle any exception on the exchange and afterwards release the exchange.- Parameters:
exchange- the exchangeautoRelease- whether the exchange was created with auto release- Returns:
- the default callback
-