Package org.apache.camel.spi
Interface ExchangeFactory
-
- All Superinterfaces:
AutoCloseable
,CamelContextAware
,NonManagedService
,PooledObjectFactory<Exchange>
,RouteIdAware
,Service
public interface ExchangeFactory extends PooledObjectFactory<Exchange>, NonManagedService, RouteIdAware
Factory used byConsumer
to create CamelExchange
holding the incoming message received by the consumer. This factory is only forConsumer
's to give control on howExchange
are created and comes into Camel. Each Camel component that provides aConsumer
should use thisExchangeFactory
. There may be other parts in Camel that createsExchange
such as sub exchanges from Splitter EIP, but they are not part of this contract as we only want to control the createdExchange
that comes into Camel viaConsumer
orPollingConsumer
. The factory is pluggable which allows using different strategies. The default factory will create a newExchange
instance, and the pooled factory will pool and reuse exchanges.- See Also:
ProcessorExchangeFactory
,PooledExchange
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.camel.spi.PooledObjectFactory
PooledObjectFactory.Statistics
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Exchange
create(boolean autoRelease)
Gets a newExchange
Exchange
create(Endpoint fromEndpoint, boolean autoRelease)
Gets a newExchange
Consumer
getConsumer()
The consumer using this factory.ExchangeFactory
newExchangeFactory(Consumer consumer)
Creates a newExchangeFactory
that is private for the given consumer.default boolean
release(Exchange exchange)
Releases the exchange back into the pool-
Methods inherited from interface org.apache.camel.CamelContextAware
getCamelContext, setCamelContext
-
Methods inherited from interface org.apache.camel.spi.PooledObjectFactory
acquire, getCapacity, getSize, getStatistics, isPooled, isStatisticsEnabled, purge, resetStatistics, setCapacity, setStatisticsEnabled
-
Methods inherited from interface org.apache.camel.spi.RouteIdAware
getRouteId, setRouteId
-
-
-
-
Field Detail
-
FACTORY
static final String FACTORY
Service factory key.- See Also:
- Constant Field Values
-
-
Method Detail
-
getConsumer
Consumer getConsumer()
The consumer using this factory.
-
newExchangeFactory
ExchangeFactory newExchangeFactory(Consumer consumer)
Creates a newExchangeFactory
that is private for the given consumer.- Parameters:
consumer
- the consumer that will use the createdExchangeFactory
- Returns:
- the created factory.
-
create
Exchange create(boolean autoRelease)
Gets a newExchange
- Parameters:
autoRelease
- whether to auto release the exchange when routing is complete viaUnitOfWork
-
create
Exchange create(Endpoint fromEndpoint, boolean autoRelease)
Gets a newExchange
- Parameters:
autoRelease
- whether to auto release the exchange when routing is complete viaUnitOfWork
fromEndpoint
- the from endpoint
-
release
default boolean release(Exchange exchange)
Releases the exchange back into the pool- Specified by:
release
in interfacePooledObjectFactory<Exchange>
- Parameters:
exchange
- the exchange- Returns:
- true if released into the pool, or false if something went wrong and the exchange was discarded
-
-