Interface ExchangeFactory

All Superinterfaces:
AutoCloseable, CamelContextAware, 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:
  • Field Details

  • Method Details

    • getConsumer

      Consumer getConsumer()
      The consumer using this factory.
    • newExchangeFactory

      ExchangeFactory newExchangeFactory(Consumer consumer)
      Creates a new ExchangeFactory that is private for the given consumer.
      Parameters:
      consumer - the consumer that will use the created ExchangeFactory
      Returns:
      the created factory.
    • create

      Exchange create(boolean autoRelease)
      Gets a new Exchange
      Parameters:
      autoRelease - whether to auto release the exchange when routing is complete via UnitOfWork
    • create

      Exchange create(Endpoint fromEndpoint, boolean autoRelease)
      Gets a new Exchange
      Parameters:
      autoRelease - whether to auto release the exchange when routing is complete via UnitOfWork
      fromEndpoint - the from endpoint
    • release

      default boolean release(Exchange exchange)
      Releases the exchange back into the pool
      Specified by:
      release in interface PooledObjectFactory<Exchange>
      Parameters:
      exchange - the exchange
      Returns:
      true if released into the pool, or false if something went wrong and the exchange was discarded