public interface ExchangeFactory extends PooledObjectFactory<Exchange>, NonManagedService, RouteIdAware
Consumer to create Camel Exchange holding the incoming message received by the
consumer.
This factory is only for Consumer's to give control on how Exchange are created and comes into Camel.
Each Camel component that provides a Consumer should use this ExchangeFactory. There may be other
parts in Camel that creates Exchange such as sub exchanges from Splitter EIP, but they are not part of this
contract as we only want to control the created Exchange that comes into Camel via Consumer or
PollingConsumer.
The factory is pluggable which allows to use different strategies. The default factory will create a new
Exchange instance, and the pooled factory will pool and reuse exchanges.ProcessorExchangeFactory,
PooledExchangePooledObjectFactory.Statistics| Modifier and Type | Field and Description |
|---|---|
static String |
FACTORY
Service factory key.
|
| Modifier and Type | Method and Description |
|---|---|
Exchange |
create(boolean autoRelease)
Gets a new
Exchange |
Exchange |
create(Endpoint fromEndpoint,
boolean autoRelease)
Gets a new
Exchange |
Consumer |
getConsumer()
The consumer using this factory.
|
ExchangeFactory |
newExchangeFactory(Consumer consumer)
Creates a new
ExchangeFactory that is private for the given consumer. |
default boolean |
release(Exchange exchange)
Releases the exchange back into the pool
|
acquire, getCapacity, getSize, getStatistics, isPooled, isStatisticsEnabled, purge, resetStatistics, setCapacity, setStatisticsEnabledgetCamelContext, setCamelContext, trySetCamelContextgetRouteId, setRouteIdstatic final String FACTORY
Consumer getConsumer()
ExchangeFactory newExchangeFactory(Consumer consumer)
ExchangeFactory that is private for the given consumer.consumer - the consumer that will use the created ExchangeFactoryExchange create(boolean autoRelease)
ExchangeautoRelease - whether to auto release the exchange when routing is complete via UnitOfWorkExchange create(Endpoint fromEndpoint, boolean autoRelease)
ExchangeautoRelease - whether to auto release the exchange when routing is complete via UnitOfWorkfromEndpoint - the from endpointdefault boolean release(Exchange exchange)
release in interface PooledObjectFactory<Exchange>exchange - the exchangeApache Camel