public class DefaultFluentProducerTemplate extends ServiceSupport implements FluentProducerTemplate
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Constructor and Description |
|---|
DefaultFluentProducerTemplate(CamelContext context) |
| Modifier and Type | Method and Description |
|---|---|
Future<Object> |
asyncRequest()
Sends asynchronously to the given endpoint (InOut).
|
<T> Future<T> |
asyncRequest(Class<T> type)
Sends asynchronously to the given endpoint (InOut).
|
Future<Exchange> |
asyncSend()
Sends asynchronously to the given endpoint (InOnly).
|
void |
cleanUp()
Cleanup the cache (purging stale entries)
|
FluentProducerTemplate |
clearAll()
Remove the body and headers.
|
FluentProducerTemplate |
clearBody()
Remove the body.
|
FluentProducerTemplate |
clearHeaders()
Remove the headers.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
int |
getCurrentCacheSize()
Gets an approximated size of the current cached resources in the backing cache pools.
|
Endpoint |
getDefaultEndpoint()
Get the default endpoint to use if none is specified
|
int |
getMaximumCacheSize()
Gets the maximum cache size used in the backing cache pools.
|
boolean |
isEventNotifierEnabled()
Whether the
EventNotifier should be
used by this ProducerTemplate to send events about the Exchange
being sent. |
static FluentProducerTemplate |
on(CamelContext context)
Create the FluentProducerTemplate by setting the camel context
|
Object |
request()
Send to an endpoint (InOut) returning any result output body.
|
<T> T |
request(Class<T> type)
Send to an endpoint (InOut).
|
Exchange |
send()
Send to an endpoint (InOnly)
|
void |
setDefaultEndpoint(Endpoint defaultEndpoint)
Sets the default endpoint to use if none is specified
|
void |
setDefaultEndpointUri(String endpointUri)
Sets the default endpoint uri to use if none is specified
|
void |
setEventNotifierEnabled(boolean eventNotifierEnabled)
Sets whether the
EventNotifier should be
used by this ProducerTemplate to send events about the Exchange
being sent. |
void |
setMaximumCacheSize(int maximumCacheSize)
Sets a custom maximum cache size to use in the backing cache pools.
|
FluentProducerTemplate |
to(Endpoint endpoint)
Endpoint to send to
|
FluentProducerTemplate |
to(String endpointUri)
Endpoint to send to
|
FluentProducerTemplate |
withBody(Object body)
Set the message body
|
FluentProducerTemplate |
withBodyAs(Object body,
Class<?> type)
Set the message body after converting it to the given type
|
FluentProducerTemplate |
withExchange(Exchange exchange)
Set the exchange to use for send.
|
FluentProducerTemplate |
withExchange(Supplier<Exchange> exchangeSupplier)
Set the exchangeSupplier which will be invoke to get the exchange to be
used for send.
|
FluentProducerTemplate |
withHeader(String key,
Object value)
Set the header
|
FluentProducerTemplate |
withProcessor(Processor processor)
Set the processor to use for send/request.
|
FluentProducerTemplate |
withProcessor(Supplier<Processor> processorSupplier)
Set the processorSupplier which will be invoke to get the processor to be
used for send/request.
|
FluentProducerTemplate |
withTemplateCustomizer(Consumer<ProducerTemplate> templateCustomizer)
To customize the producer template for advanced usage like to set the
executor service to use.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendpublic DefaultFluentProducerTemplate(CamelContext context)
public CamelContext getCamelContext()
FluentProducerTemplateCamelContextgetCamelContext in interface FluentProducerTemplatepublic int getCurrentCacheSize()
FluentProducerTemplategetCurrentCacheSize in interface FluentProducerTemplatepublic void cleanUp()
FluentProducerTemplatecleanUp in interface FluentProducerTemplatepublic void setDefaultEndpointUri(String endpointUri)
FluentProducerTemplatesetDefaultEndpointUri in interface FluentProducerTemplateendpointUri - the default endpoint uripublic Endpoint getDefaultEndpoint()
FluentProducerTemplategetDefaultEndpoint in interface FluentProducerTemplatepublic void setDefaultEndpoint(Endpoint defaultEndpoint)
FluentProducerTemplatesetDefaultEndpoint in interface FluentProducerTemplatedefaultEndpoint - the default endpoint instancepublic int getMaximumCacheSize()
FluentProducerTemplategetMaximumCacheSize in interface FluentProducerTemplatepublic void setMaximumCacheSize(int maximumCacheSize)
FluentProducerTemplatesetMaximumCacheSize in interface FluentProducerTemplatemaximumCacheSize - the custom maximum cache sizepublic boolean isEventNotifierEnabled()
FluentProducerTemplateEventNotifier should be
used by this ProducerTemplate to send events about the Exchange
being sent.isEventNotifierEnabled in interface FluentProducerTemplatepublic void setEventNotifierEnabled(boolean eventNotifierEnabled)
FluentProducerTemplateEventNotifier should be
used by this ProducerTemplate to send events about the Exchange
being sent.
By default this is enabled.setEventNotifierEnabled in interface FluentProducerTemplateeventNotifierEnabled - true to enable, false to disable.public FluentProducerTemplate clearAll()
FluentProducerTemplateclearAll in interface FluentProducerTemplatepublic FluentProducerTemplate withHeader(String key, Object value)
FluentProducerTemplatewithHeader in interface FluentProducerTemplatekey - the key of the headervalue - the value of the headerpublic FluentProducerTemplate clearHeaders()
FluentProducerTemplateclearHeaders in interface FluentProducerTemplatepublic FluentProducerTemplate withBody(Object body)
FluentProducerTemplatewithBody in interface FluentProducerTemplatebody - the bodypublic FluentProducerTemplate withBodyAs(Object body, Class<?> type)
FluentProducerTemplatewithBodyAs in interface FluentProducerTemplatebody - the bodytype - the type which the body should be converted topublic FluentProducerTemplate clearBody()
FluentProducerTemplateclearBody in interface FluentProducerTemplatepublic FluentProducerTemplate withTemplateCustomizer(Consumer<ProducerTemplate> templateCustomizer)
FluentProducerTemplate
FluentProducerTemplate.on(context)
.withTemplateCustomizer(
template -> {
template.setExecutorService(myExecutor);
template.setMaximumCacheSize(10);
}
)
.withBody("the body")
.to("direct:start")
.request()
Note that it is invoked only once.withTemplateCustomizer in interface FluentProducerTemplatetemplateCustomizer - the customizerpublic FluentProducerTemplate withExchange(Exchange exchange)
FluentProducerTemplatewithExchange in interface FluentProducerTemplateexchange - the exchangepublic FluentProducerTemplate withExchange(Supplier<Exchange> exchangeSupplier)
FluentProducerTemplatewithExchange in interface FluentProducerTemplateexchangeSupplier - the supplierpublic FluentProducerTemplate withProcessor(Processor processor)
FluentProducerTemplate
FluentProducerTemplate.on(context)
.withProcessor(
exchange -> {
exchange.getIn().setHeader("Key1", "Val1");
exchange.getIn().setHeader("Key2", "Val2");
exchange.getIn().setBody("the body");
}
)
.to("direct:start")
.request()
withProcessor in interface FluentProducerTemplatepublic FluentProducerTemplate withProcessor(Supplier<Processor> processorSupplier)
FluentProducerTemplatewithProcessor in interface FluentProducerTemplateprocessorSupplier - the supplierpublic FluentProducerTemplate to(String endpointUri)
FluentProducerTemplateto in interface FluentProducerTemplateendpointUri - the endpoint URI to send topublic FluentProducerTemplate to(Endpoint endpoint)
FluentProducerTemplateto in interface FluentProducerTemplateendpoint - the endpoint to send topublic Object request() throws CamelExecutionException
FluentProducerTemplaterequest in interface FluentProducerTemplateCamelExecutionException - is thrown if error occurredpublic <T> T request(Class<T> type) throws CamelExecutionException
FluentProducerTemplaterequest in interface FluentProducerTemplatetype - the expected response typeCamelExecutionException - is thrown if error occurredpublic Future<Object> asyncRequest()
FluentProducerTemplateasyncRequest in interface FluentProducerTemplatepublic <T> Future<T> asyncRequest(Class<T> type)
FluentProducerTemplateasyncRequest in interface FluentProducerTemplatetype - the expected response typepublic Exchange send() throws CamelExecutionException
FluentProducerTemplatesend in interface FluentProducerTemplateCamelExecutionException - is thrown if error occurredpublic Future<Exchange> asyncSend()
FluentProducerTemplateasyncSend in interface FluentProducerTemplatepublic static FluentProducerTemplate on(CamelContext context)
context - the camel contextprotected void doStart() throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class ServiceSupportExceptionServiceSupport.doStop()protected void doStop() throws Exception
ServiceSupportServiceSupport.doStop() method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext is shutting down.doStop in class ServiceSupportExceptionServiceSupport.doStart()Apache Camel