Package org.apache.camel.spi
Interface ExchangeFactory
- All Superinterfaces:
AutoCloseable,CamelContextAware,HasCamelContext,NonManagedService,PooledObjectFactory<Exchange>,RouteIdAware,Service
public interface ExchangeFactory
extends PooledObjectFactory<Exchange>, NonManagedService, RouteIdAware
Factory used by
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 using different strategies. The default factory will create a new
Exchange instance, and the pooled factory will pool and reuse exchanges.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.spi.PooledObjectFactory
PooledObjectFactory.Statistics -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncreate(boolean autoRelease) Gets a newExchangeGets a newExchangeThe consumer using this factory.newExchangeFactory(Consumer consumer) Creates a newExchangeFactorythat is private for the given consumer.default booleanReleases the exchange back into the poolMethods inherited from interface org.apache.camel.CamelContextAware
setCamelContextMethods inherited from interface org.apache.camel.spi.HasCamelContext
getCamelContextMethods inherited from interface org.apache.camel.spi.PooledObjectFactory
acquire, getCapacity, getSize, getStatistics, isPooled, isStatisticsEnabled, purge, resetStatistics, setCapacity, setStatisticsEnabledMethods inherited from interface org.apache.camel.spi.RouteIdAware
getRouteId, setRouteId
-
Field Details
-
FACTORY
Service factory key.- See Also:
-
-
Method Details
-
getConsumer
Consumer getConsumer()The consumer using this factory. -
newExchangeFactory
Creates a newExchangeFactorythat is private for the given consumer.- Parameters:
consumer- the consumer that will use the createdExchangeFactory- Returns:
- the created factory.
-
create
Gets a newExchange- Parameters:
autoRelease- whether to auto release the exchange when routing is complete viaUnitOfWork
-
create
Gets a newExchange- Parameters:
fromEndpoint- the from endpointautoRelease- whether to auto release the exchange when routing is complete viaUnitOfWork
-
release
Releases the exchange back into the pool- Specified by:
releasein interfacePooledObjectFactory<Exchange>- Parameters:
exchange- the exchange- Returns:
- true if released into the pool, or false if something went wrong and the exchange was discarded
-