Package org.apache.camel.spi
Interface ProducerCache
- All Superinterfaces:
AutoCloseable
,Service
Cache containing created
Producer
.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Callback for sending a exchange message to a endpoint using anAsyncProcessor
capable producer. -
Method Summary
Modifier and TypeMethodDescriptionacquireProducer
(Endpoint endpoint) Acquires a pooled producer which you must release back again after usage using thereleaseProducer(org.apache.camel.Endpoint, org.apache.camel.AsyncProducer)
method.asyncSendExchange
(Endpoint endpoint, ExchangePattern pattern, Processor processor, Processor resultProcessor, Exchange exchange, CompletableFuture<Exchange> future) Asynchronously sends an exchange to an endpoint using a suppliedProcessor
to populate the exchangevoid
cleanUp()
Cleanup the cache (purging stale entries)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.int
Gets the maximum cache size (capacity).Gets the endpoint statisticsGets the source which uses this cacheboolean
WhetherEventNotifier
is enabledvoid
purge()
Purges this cachevoid
releaseProducer
(Endpoint endpoint, AsyncProducer producer) Releases an acquired producer back after usage.Sends the exchange to the given endpoint.void
setEventNotifierEnabled
(boolean eventNotifierEnabled) Sets whetherEventNotifier
is enabledint
size()
Returns the current size of the cache
-
Method Details
-
acquireProducer
Acquires a pooled producer which you must release back again after usage using thereleaseProducer(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
Releases an acquired producer back after usage.- Parameters:
endpoint
- the endpointproducer
- the producer to release
-
send
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 toexchange
- 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 suppliedProcessor
to populate the exchangeThis 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 topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
processor
- the transformer used to populate the new exchangeresultProcessor
- 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()WhetherEventNotifier
is enabled -
setEventNotifierEnabled
void setEventNotifierEnabled(boolean eventNotifierEnabled) Sets whetherEventNotifier
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 toexchange
- the exchange, can be null if so then create a new exchange from the producercallback
- the asynchronous callbackproducerCallback
- the producer template callback to be executed- Returns:
- (doneSync) true to continue execute synchronously, false to continue being executed asynchronously
-