Interface ProducerCache

All Superinterfaces:
AutoCloseable, Service

public interface ProducerCache extends Service
Cache containing created Producer.
  • Method Details

    • acquireProducer

      AsyncProducer acquireProducer(Endpoint endpoint)
      Acquires a pooled producer which you must release back again after usage using the releaseProducer(org.apache.camel.Endpoint, org.apache.camel.AsyncProducer) method.

      If the producer is currently starting then the cache will wait at most 30 seconds for the producer to finish starting and be ready for use.

      Parameters:
      endpoint - the endpoint
      Returns:
      the producer
    • releaseProducer

      void releaseProducer(Endpoint endpoint, AsyncProducer producer)
      Releases an acquired producer back after usage.
      Parameters:
      endpoint - the endpoint
      producer - the producer to release
    • send

      Exchange send(Endpoint endpoint, Exchange exchange, Processor resultProcessor)
      Sends the exchange to the given endpoint.

      This method will not throw an exception. If processing of the given Exchange failed then the exception is stored on the provided Exchange

      Parameters:
      endpoint - the endpoint to send the exchange to
      exchange - the exchange to send
      Throws:
      RejectedExecutionException - is thrown if CamelContext is stopped
    • asyncSendExchange

      CompletableFuture<Exchange> asyncSendExchange(Endpoint endpoint, ExchangePattern pattern, Processor processor, Processor resultProcessor, Exchange exchange, CompletableFuture<Exchange> future)
      Asynchronously sends an exchange to an endpoint using a supplied Processor to populate the exchange

      This method will neither throw an exception nor complete future exceptionally. If processing of the given Exchange failed then the exception is stored on the return Exchange

      Parameters:
      endpoint - the endpoint to send the exchange to
      pattern - the message ExchangePattern such as ExchangePattern.InOnly or ExchangePattern.InOut
      processor - the transformer used to populate the new exchange
      resultProcessor - a processor to process the exchange when the send is complete.
      exchange - an exchange to use in processing. Exchange will be created if parameter is null.
      future - the preexisting future to complete when processing is done or null if to create new one
      Returns:
      future that completes with exchange when processing is done. Either passed into future parameter or new one if parameter was null
    • getSource

      Object getSource()
      Gets the source which uses this cache
      Returns:
      the source
    • size

      int size()
      Returns the current size of the cache
      Returns:
      the current size
    • getCapacity

      int getCapacity()
      Gets the maximum cache size (capacity).
      Returns:
      the capacity
    • purge

      void purge()
      Purges this cache
    • cleanUp

      void cleanUp()
      Cleanup the cache (purging stale entries)
    • isEventNotifierEnabled

      boolean isEventNotifierEnabled()
      Whether EventNotifier is enabled
    • setEventNotifierEnabled

      void setEventNotifierEnabled(boolean eventNotifierEnabled)
      Sets whether EventNotifier is enabled
    • getEndpointUtilizationStatistics

      EndpointUtilizationStatistics getEndpointUtilizationStatistics()
      Gets the endpoint statistics
    • doInAsyncProducer

      boolean doInAsyncProducer(Endpoint endpoint, Exchange exchange, AsyncCallback callback, ProducerCache.AsyncProducerCallback producerCallback)
      Sends an exchange to an endpoint using a supplied callback supporting the asynchronous routing engine.

      If an exception was thrown during processing, it would be set on the given Exchange

      Parameters:
      endpoint - the endpoint to send the exchange to
      exchange - the exchange, can be null if so then create a new exchange from the producer
      callback - the asynchronous callback
      producerCallback - the producer template callback to be executed
      Returns:
      (doneSync) true to continue execute synchronously, false to continue being executed asynchronously