Package org.apache.camel.spi
Interface ProducerCache
-
- All Superinterfaces:
AutoCloseable,Service
public interface ProducerCache extends Service
Cache containing createdProducer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceProducerCache.AsyncProducerCallbackCallback for sending a exchange message to a endpoint using anAsyncProcessorcapable producer.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AsyncProduceracquireProducer(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.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 suppliedProcessorto populate the exchangevoidcleanUp()Cleanup the cache (purging stale entries)booleandoInAsyncProducer(Endpoint endpoint, Exchange exchange, AsyncCallback callback, ProducerCache.AsyncProducerCallback producerCallback)Sends an exchange to an endpoint using a supplied callback supporting the asynchronous routing engine.intgetCapacity()Gets the maximum cache size (capacity).EndpointUtilizationStatisticsgetEndpointUtilizationStatistics()Gets the endpoint statisticsObjectgetSource()Gets the source which uses this cachebooleanisEventNotifierEnabled()WhetherEventNotifieris enabledvoidpurge()Purges this cachevoidreleaseProducer(Endpoint endpoint, AsyncProducer producer)Releases an acquired producer back after usage.Exchangesend(Endpoint endpoint, Exchange exchange, Processor resultProcessor)Sends the exchange to the given endpoint.voidsetEventNotifierEnabled(boolean eventNotifierEnabled)Sets whetherEventNotifieris enabledintsize()Returns the current size of the cache
-
-
-
Method Detail
-
acquireProducer
AsyncProducer acquireProducer(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. 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 endpointproducer- 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 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 suppliedProcessorto 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 messageExchangePatternsuch asExchangePattern.InOnlyorExchangePattern.InOutprocessor- 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()
WhetherEventNotifieris enabled
-
setEventNotifierEnabled
void setEventNotifierEnabled(boolean eventNotifierEnabled)
Sets whetherEventNotifieris 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
-
-