Package org.apache.camel
Interface ProducerTemplate
- All Superinterfaces:
AutoCloseable
,Service
Template for working with Camel and sending
Important: Read the javadoc of each method carefully to ensure the behavior of the method is understood. Some methods is for InOnly, others for InOut MEP. And some methods throws
The
All the methods which sends a message may throw
All the sendBody or requestBody methods will return the content according to this strategy:
Before using the template it must be started. And when you are done using the template, make sure to
Important note on usage: See this FAQ entry before using.
Message
instances in an Exchange
to an Endpoint
.
Important: Read the javadoc of each method carefully to ensure the behavior of the method is understood. Some methods is for InOnly, others for InOut MEP. And some methods throws
CamelExecutionException
while others stores any thrown exception on the returned
Exchange
. The
ProducerTemplate
is thread safe. All the methods which sends a message may throw
FailedToCreateProducerException
in case the Producer
could not be created. Or a NoSuchEndpointException
if the endpoint could not be resolved. There may be other
related exceptions being thrown which occurs before the Producer
has started sending the message.
All the sendBody or requestBody methods will return the content according to this strategy:
- throws
CamelExecutionException
if processing failed during routing with the caused exception wrapped - The fault.body if there is a fault message set and its not null
- Either IN or OUT body according to the message exchange pattern. If the pattern is Out capable then the OUT body is returned, otherwise IN.
Before using the template it must be started. And when you are done using the template, make sure to
Service.stop()
the template. Important note on usage: See this FAQ entry before using.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionasyncRequestBody
(String endpointUri, Object body) Sends an asynchronous body to the given endpoint.<T> CompletableFuture
<T> asyncRequestBody
(String endpointUri, Object body, Class<T> type) Sends an asynchronous body to the given endpoint.asyncRequestBody
(Endpoint endpoint, Object body) Sends an asynchronous body to the given endpoint.<T> CompletableFuture
<T> asyncRequestBody
(Endpoint endpoint, Object body, Class<T> type) Sends an asynchronous body to the given endpoint.asyncRequestBodyAndHeader
(String endpointUri, Object body, String header, Object headerValue) Sends an asynchronous body to the given endpoint.<T> CompletableFuture
<T> asyncRequestBodyAndHeader
(String endpointUri, Object body, String header, Object headerValue, Class<T> type) Sends an asynchronous body to the given endpoint.asyncRequestBodyAndHeader
(Endpoint endpoint, Object body, String header, Object headerValue) Sends an asynchronous body to the given endpoint.<T> CompletableFuture
<T> asyncRequestBodyAndHeader
(Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type) Sends an asynchronous body to the given endpoint.Sends an asynchronous body to the given endpoint.<T> CompletableFuture
<T> asyncRequestBodyAndHeaders
(String endpointUri, Object body, Map<String, Object> headers, Class<T> type) Sends an asynchronous body to the given endpoint.Sends an asynchronous body to the given endpoint.<T> CompletableFuture
<T> asyncRequestBodyAndHeaders
(Endpoint endpoint, Object body, Map<String, Object> headers, Class<T> type) Sends an asynchronous body to the given endpoint.Sends an asynchronous exchange to the given endpoint.Sends an asynchronous exchange to the given endpoint.Sends an asynchronous exchange to the given endpoint.Sends an asynchronous exchange to the given endpoint.asyncSendBody
(String endpointUri, Object body) Sends an asynchronous body to the given endpoint.asyncSendBody
(Endpoint endpoint, Object body) Sends an asynchronous body to the given endpoint.void
cleanUp()
Cleanup the cache (purging stale entries)<T> T
extractFutureBody
(Future<?> future, long timeout, TimeUnit unit, Class<T> type) Gets the response body from the future handle, will wait at most the given time for the response to be ready.<T> T
extractFutureBody
(Future<?> future, Class<T> type) Gets the response body from the future handle, will wait until the response is ready.Get theCamelContext
int
Gets an approximated size of the current cached resources in the backing cache pools.Get the default endpoint to use if none is specifiedint
Gets the maximum cache size used in the backing cache pools.boolean
Whether theEventNotifier
should be used by thisProducerTemplate
to send events about theExchange
being sent.boolean
Reports if async* methods will dispatch processing from the calling thread (false) or through executor (true).Sends an exchange to an endpoint using a supplied processor Uses anExchangePattern.InOut
message exchange pattern.Sends an exchange to an endpoint using a supplied processor Uses anExchangePattern.InOut
message exchange pattern.requestBody
(Object body) Sends the body to the default endpoint and returns the result content Uses anExchangePattern.InOut
message exchange pattern.<T> T
requestBody
(Object body, Class<T> type) Sends the body to the default endpoint and returns the result content Uses anExchangePattern.InOut
message exchange pattern.requestBody
(String endpointUri, Object body) Send the body to an endpoint returning any result output body.<T> T
requestBody
(String endpointUri, Object body, Class<T> type) Send the body to an endpoint returning any result output body.requestBody
(Endpoint endpoint, Object body) Send the body to an endpoint returning any result output body.<T> T
requestBody
(Endpoint endpoint, Object body, Class<T> type) Send the body to an endpoint returning any result output body.requestBodyAndHeader
(Object body, String header, Object headerValue) Sends the body to the default endpoint and returns the result content Uses anExchangePattern.InOut
message exchange pattern.requestBodyAndHeader
(String endpointUri, Object body, String header, Object headerValue) Send the body to an endpoint returning any result output body.<T> T
requestBodyAndHeader
(String endpointUri, Object body, String header, Object headerValue, Class<T> type) Send the body to an endpoint returning any result output body.requestBodyAndHeader
(Endpoint endpoint, Object body, String header, Object headerValue) Send the body to an endpoint returning any result output body.<T> T
requestBodyAndHeader
(Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type) Send the body to an endpoint returning any result output body.requestBodyAndHeaders
(Object body, Map<String, Object> headers) Sends the body to the default endpoint and returns the result content Uses anExchangePattern.InOut
message exchange pattern.Sends the body to an endpoint with the specified headers and header values.<T> T
Sends the body to an endpoint with the specified headers and header values.Sends the body to an endpoint with the specified headers and header values.<T> T
Sends the body to an endpoint with the specified headers and header values.Sends the exchange to the given endpoint
send
(String endpointUri, ExchangePattern pattern, Processor processor) Sends an exchange to an endpoint using a supplied processor
Sends an exchange to an endpoint using a supplied processor
Sends the exchange to the given endpoint
send
(Endpoint endpoint, ExchangePattern pattern, Processor processor) Sends an exchange to an endpoint using a supplied processor
send
(Endpoint endpoint, ExchangePattern pattern, Processor processor, Processor resultProcessor) Sends an exchange to an endpoint using a supplied processor
Sends an exchange to an endpoint using a supplied processor
Sends the exchange to the default endpoint
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.Sends an exchange to the default endpoint using a supplied processor
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.void
Sends the body to the default endpoint
void
Send the body to an endpoint
sendBody
(String endpointUri, ExchangePattern pattern, Object body) Send the body to an endpoint returning any result output body
void
Send the body to an endpoint
sendBody
(Endpoint endpoint, ExchangePattern pattern, Object body) void
sendBodyAndHeader
(Object body, String header, Object headerValue) Sends the body to the default endpoint with a specified header and header value
void
sendBodyAndHeader
(String endpointUri, Object body, String header, Object headerValue) Sends the body to an endpoint with a specified header and header value
sendBodyAndHeader
(String endpoint, ExchangePattern pattern, Object body, String header, Object headerValue) Sends the body to an endpoint with a specified header and header value
void
sendBodyAndHeader
(Endpoint endpoint, Object body, String header, Object headerValue) Sends the body to an endpoint with a specified header and header value
sendBodyAndHeader
(Endpoint endpoint, ExchangePattern pattern, Object body, String header, Object headerValue) Sends the body to an endpoint with a specified header and header value
void
sendBodyAndHeaders
(Object body, Map<String, Object> headers) Sends the body to the default endpoint with the specified headers and header values
void
Sends the body to an endpoint with the specified headers and header values
sendBodyAndHeaders
(String endpointUri, ExchangePattern pattern, Object body, Map<String, Object> headers) Sends the body to an endpoint with the specified headers and header values
void
Sends the body to an endpoint with the specified headers and header values
sendBodyAndHeaders
(Endpoint endpoint, ExchangePattern pattern, Object body, Map<String, Object> headers) Sends the body to an endpoint with the specified headers and header values
void
sendBodyAndProperty
(Object body, String property, Object propertyValue) Sends the body to the default endpoint with a specified property and property value
void
sendBodyAndProperty
(String endpointUri, Object body, String property, Object propertyValue) Sends the body to an endpoint with a specified property and property value
sendBodyAndProperty
(String endpoint, ExchangePattern pattern, Object body, String property, Object propertyValue) Sends the body to an endpoint with a specified property and property value
void
sendBodyAndProperty
(Endpoint endpoint, Object body, String property, Object propertyValue) Sends the body to an endpoint with a specified property and property value
sendBodyAndProperty
(Endpoint endpoint, ExchangePattern pattern, Object body, String property, Object propertyValue) Sends the body to an endpoint with a specified property and property value
void
setDefaultEndpoint
(Endpoint defaultEndpoint) Sets the default endpoint to use if none is specifiedvoid
setDefaultEndpointUri
(String endpointUri) Sets the default endpoint uri to use if none is specifiedvoid
setEventNotifierEnabled
(boolean enabled) Sets whether theEventNotifier
should be used by thisProducerTemplate
to send events about theExchange
being sent.void
setExecutorService
(ExecutorService executorService) Sets a custom executor service to use for async messaging.void
setMaximumCacheSize
(int maximumCacheSize) Sets a custom maximum cache size to use in the backing cache pools.void
setThreadedAsyncMode
(boolean useExecutor) Reports if async* methods will dispatch processing from the calling thread (false) or through executor (true).
-
Method Details
-
getCamelContext
CamelContext getCamelContext()Get theCamelContext
- Returns:
- camelContext the Camel context
-
getMaximumCacheSize
int getMaximumCacheSize()Gets the maximum cache size used in the backing cache pools.- Returns:
- the maximum cache size
-
setMaximumCacheSize
void setMaximumCacheSize(int maximumCacheSize) Sets a custom maximum cache size to use in the backing cache pools.- Parameters:
maximumCacheSize
- the custom maximum cache size
-
getCurrentCacheSize
int getCurrentCacheSize()Gets an approximated size of the current cached resources in the backing cache pools.- Returns:
- the size of current cached resources
-
isThreadedAsyncMode
boolean isThreadedAsyncMode()Reports if async* methods will dispatch processing from the calling thread (false) or through executor (true). In both cases asynchronous engine will be used, so this non-threaded can be useful for high-speed non-blocking processing.- Returns:
- if async* methods will dispatch processing with the executor
-
setThreadedAsyncMode
void setThreadedAsyncMode(boolean useExecutor) Reports if async* methods will dispatch processing from the calling thread (false) or through executor (true). In both cases asynchronous engine will be used, so this non-threaded can be useful for high-speed non-blocking processing.- Parameters:
useExecutor
- if async* methods will dispatch processing with the executor
-
getDefaultEndpoint
Endpoint getDefaultEndpoint()Get the default endpoint to use if none is specified- Returns:
- the default endpoint instance
-
setDefaultEndpoint
Sets the default endpoint to use if none is specified- Parameters:
defaultEndpoint
- the default endpoint instance
-
setDefaultEndpointUri
Sets the default endpoint uri to use if none is specified- Parameters:
endpointUri
- the default endpoint uri
-
setEventNotifierEnabled
void setEventNotifierEnabled(boolean enabled) Sets whether theEventNotifier
should be used by thisProducerTemplate
to send events about theExchange
being sent. By default this is enabled.- Parameters:
enabled
- true to enable, false to disable.
-
isEventNotifierEnabled
boolean isEventNotifierEnabled()Whether theEventNotifier
should be used by thisProducerTemplate
to send events about theExchange
being sent.- Returns:
- true if enabled, false otherwise
-
cleanUp
void cleanUp()Cleanup the cache (purging stale entries) -
send
Sends the exchange to the default endpoint
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
exchange
- the exchange to send- Returns:
- the returned exchange
-
send
Sends an exchange to the default endpoint using a supplied processor
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
processor
- the transformer used to populate the new exchangeProcessor
to populate the exchange- Returns:
- the returned exchange
-
sendBody
Sends the body to the default endpoint
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
body
- the payload to send- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeader
void sendBodyAndHeader(Object body, String header, Object headerValue) throws CamelExecutionException Sends the body to the default endpoint with a specified header and header value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
body
- the payload to sendheader
- the header nameheaderValue
- the header value- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndProperty
void sendBodyAndProperty(Object body, String property, Object propertyValue) throws CamelExecutionException Sends the body to the default endpoint with a specified property and property value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
body
- the payload to sendproperty
- the property namepropertyValue
- the property value- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeaders
Sends the body to the default endpoint with the specified headers and header values
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
body
- the payload to sendheaders
- the headers- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
send
Sends the exchange to the given endpoint
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
endpointUri
- the endpoint URI to send the exchange toexchange
- the exchange to send- Returns:
- the returned exchange
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
send
Sends an exchange to an endpoint using a supplied processor
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
endpointUri
- the endpoint URI to send the exchange toprocessor
- the transformer used to populate the new exchangeProcessor
to populate the exchange- Returns:
- the returned exchange
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
send
Sends an exchange to an endpoint using a supplied processor
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
endpointUri
- the endpoint URI to send the exchange topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
processor
- the transformer used to populate the new exchangeProcessor
to populate the exchange- Returns:
- the returned exchange
-
send
Sends the exchange to the given endpoint
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
endpoint
- the endpoint to send the exchange toexchange
- the exchange to send- Returns:
- the returned exchange
-
send
Sends an exchange to an endpoint using a supplied processor
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
endpoint
- the endpoint to send the exchange toprocessor
- the transformer used to populate the new exchangeProcessor
to populate the exchange- Returns:
- the returned exchange
-
send
Sends an exchange to an endpoint using a supplied processor
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
endpoint
- the endpoint to send the exchange topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
processor
- the transformer used to populate the new exchangeProcessor
to populate the exchange- Returns:
- the returned exchange
-
send
Exchange send(Endpoint endpoint, ExchangePattern pattern, Processor processor, Processor resultProcessor) Sends an exchange to an endpoint using a supplied processor
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- 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.Processor
to populate the exchange- Returns:
- the returned exchange
-
sendBody
Send the body to an endpoint
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the endpoint to send the exchange tobody
- the payload- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBody
Send the body to an endpoint
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send the exchange tobody
- the payload- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBody
Object sendBody(Endpoint endpoint, ExchangePattern pattern, Object body) throws CamelExecutionException Send the body to an endpoint with the givenExchangePattern
returning any result output body
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the endpoint to send the exchange topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
body
- the payload- Returns:
- the result if
ExchangePattern
is OUT capable, otherwise null - Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBody
Object sendBody(String endpointUri, ExchangePattern pattern, Object body) throws CamelExecutionException Send the body to an endpoint returning any result output body
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send the exchange topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
body
- the payload- Returns:
- the result if
ExchangePattern
is OUT capable, otherwise null - Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeader
void sendBodyAndHeader(String endpointUri, Object body, String header, Object headerValue) throws CamelExecutionException Sends the body to an endpoint with a specified header and header value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payload to sendheader
- the header nameheaderValue
- the header value- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeader
void sendBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue) throws CamelExecutionException Sends the body to an endpoint with a specified header and header value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint to send tobody
- the payload to sendheader
- the header nameheaderValue
- the header value- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeader
Object sendBodyAndHeader(Endpoint endpoint, ExchangePattern pattern, Object body, String header, Object headerValue) throws CamelExecutionException Sends the body to an endpoint with a specified header and header value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint to send topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
body
- the payload to sendheader
- the header nameheaderValue
- the header value- Returns:
- the result if
ExchangePattern
is OUT capable, otherwise null - Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeader
Object sendBodyAndHeader(String endpoint, ExchangePattern pattern, Object body, String header, Object headerValue) throws CamelExecutionException Sends the body to an endpoint with a specified header and header value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint URI to send topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
body
- the payload to sendheader
- the header nameheaderValue
- the header value- Returns:
- the result if
ExchangePattern
is OUT capable, otherwise null - Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndProperty
void sendBodyAndProperty(String endpointUri, Object body, String property, Object propertyValue) throws CamelExecutionException Sends the body to an endpoint with a specified property and property value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payload to sendproperty
- the property namepropertyValue
- the property value- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndProperty
void sendBodyAndProperty(Endpoint endpoint, Object body, String property, Object propertyValue) throws CamelExecutionException Sends the body to an endpoint with a specified property and property value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint to send tobody
- the payload to sendproperty
- the property namepropertyValue
- the property value- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndProperty
Object sendBodyAndProperty(Endpoint endpoint, ExchangePattern pattern, Object body, String property, Object propertyValue) throws CamelExecutionException Sends the body to an endpoint with a specified property and property value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint to send topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
body
- the payload to sendproperty
- the property namepropertyValue
- the property value- Returns:
- the result if
ExchangePattern
is OUT capable, otherwise null - Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndProperty
Object sendBodyAndProperty(String endpoint, ExchangePattern pattern, Object body, String property, Object propertyValue) throws CamelExecutionException Sends the body to an endpoint with a specified property and property value
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint URI to send topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
body
- the payload to sendproperty
- the property namepropertyValue
- the property value- Returns:
- the result if
ExchangePattern
is OUT capable, otherwise null - Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeaders
void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws CamelExecutionExceptionSends the body to an endpoint with the specified headers and header values
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payload to sendheaders
- headers- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeaders
void sendBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers) throws CamelExecutionExceptionSends the body to an endpoint with the specified headers and header values
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the endpoint URI to send tobody
- the payload to sendheaders
- headers- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeaders
Object sendBodyAndHeaders(String endpointUri, ExchangePattern pattern, Object body, Map<String, Object> headers) throws CamelExecutionExceptionSends the body to an endpoint with the specified headers and header values
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
body
- the payload to sendheaders
- headers- Returns:
- the result if
ExchangePattern
is OUT capable, otherwise null - Throws:
CamelExecutionException
- if the processing of the exchange failed
-
sendBodyAndHeaders
Object sendBodyAndHeaders(Endpoint endpoint, ExchangePattern pattern, Object body, Map<String, Object> headers) throws CamelExecutionExceptionSends the body to an endpoint with the specified headers and header values
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the endpoint URI to send topattern
- the messageExchangePattern
such asExchangePattern.InOnly
orExchangePattern.InOut
body
- the payload to sendheaders
- headers- Returns:
- the result if
ExchangePattern
is OUT capable, otherwise null - Throws:
CamelExecutionException
- if the processing of the exchange failed
-
request
Sends an exchange to an endpoint using a supplied processor Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
endpoint
- the Endpoint to send toprocessor
- the processor which will populate the exchange before sending- Returns:
- the result (see class javadoc)
-
request
Sends an exchange to an endpoint using a supplied processor Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange usingExchange.getException()
.- Parameters:
endpointUri
- the endpoint URI to send toprocessor
- the processor which will populate the exchange before sending- Returns:
- the result (see class javadoc)
-
requestBody
Sends the body to the default endpoint and returns the result content Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
body
- the payload to send- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBody
Sends the body to the default endpoint and returns the result content Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
body
- the payload to sendtype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBody
Send the body to an endpoint returning any result output body. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint to send tobody
- the payload- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBody
Send the body to an endpoint returning any result output body. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint to send tobody
- the payloadtype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBody
Send the body to an endpoint returning any result output body. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payload- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBody
Send the body to an endpoint returning any result output body. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payloadtype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeader
Object requestBodyAndHeader(Object body, String header, Object headerValue) throws CamelExecutionException Sends the body to the default endpoint and returns the result content Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
body
- the payloadheader
- the header nameheaderValue
- the header value- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeader
Object requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue) throws CamelExecutionException Send the body to an endpoint returning any result output body. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint to send tobody
- the payloadheader
- the header nameheaderValue
- the header value- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeader
<T> T requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type) throws CamelExecutionException Send the body to an endpoint returning any result output body. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the Endpoint to send tobody
- the payloadheader
- the header nameheaderValue
- the header valuetype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeader
Object requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue) throws CamelExecutionException Send the body to an endpoint returning any result output body. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payloadheader
- the header nameheaderValue
- the header value- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeader
<T> T requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class<T> type) throws CamelExecutionException Send the body to an endpoint returning any result output body. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payloadheader
- the header nameheaderValue
- the header valuetype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeaders
Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws CamelExecutionExceptionSends the body to an endpoint with the specified headers and header values. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payload to sendheaders
- headers- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeaders
<T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers, Class<T> type) throws CamelExecutionExceptionSends the body to an endpoint with the specified headers and header values. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpointUri
- the endpoint URI to send tobody
- the payload to sendheaders
- headerstype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeaders
Object requestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers) throws CamelExecutionExceptionSends the body to an endpoint with the specified headers and header values. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the endpoint URI to send tobody
- the payload to sendheaders
- headers- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeaders
Object requestBodyAndHeaders(Object body, Map<String, Object> headers) throws CamelExecutionExceptionSends the body to the default endpoint and returns the result content Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
body
- the payload to sendheaders
- headers- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
requestBodyAndHeaders
<T> T requestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers, Class<T> type) throws CamelExecutionExceptionSends the body to an endpoint with the specified headers and header values. Uses anExchangePattern.InOut
message exchange pattern.
Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
endpoint
- the endpoint URI to send tobody
- the payload to sendheaders
- headerstype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
setExecutorService
Sets a custom executor service to use for async messaging.- Parameters:
executorService
- the executor service.
-
asyncSend
Sends an asynchronous exchange to the given endpoint.- Parameters:
endpointUri
- the endpoint URI to send the exchange toexchange
- the exchange to send- Returns:
- a handle to be used to get the response in the future
-
asyncSend
Sends an asynchronous exchange to the given endpoint. Important: The transformer processor is invoked by a thread from the underlying thread pool, when the task is running to send the exchange asynchronously. In other words mind about thread-safety when using the transformer processor.- Parameters:
endpointUri
- the endpoint URI to send the exchange toprocessor
- the transformer used to populate the new exchange- Returns:
- a handle to be used to get the response in the future
-
asyncSendBody
Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOnly
message exchange pattern.- Parameters:
endpointUri
- the endpoint URI to send the exchange tobody
- the body to send- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBody
Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpointUri
- the endpoint URI to send the exchange tobody
- the body to send- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBodyAndHeader
CompletableFuture<Object> asyncRequestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue) Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpointUri
- the endpoint URI to send the exchange tobody
- the body to sendheader
- the header nameheaderValue
- the header value- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBodyAndHeaders
CompletableFuture<Object> asyncRequestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpointUri
- the endpoint URI to send the exchange tobody
- the body to sendheaders
- headers- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBody
Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpointUri
- the endpoint URI to send the exchange tobody
- the body to sendtype
- the expected response type- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBodyAndHeader
<T> CompletableFuture<T> asyncRequestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class<T> type) Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpointUri
- the endpoint URI to send the exchange tobody
- the body to sendheader
- the header nameheaderValue
- the header valuetype
- the expected response type- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBodyAndHeaders
<T> CompletableFuture<T> asyncRequestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers, Class<T> type) Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpointUri
- the endpoint URI to send the exchange tobody
- the body to sendheaders
- headerstype
- the expected response type- Returns:
- a handle to be used to get the response in the future
-
asyncSend
Sends an asynchronous exchange to the given endpoint.- Parameters:
endpoint
- the endpoint to send the exchange toexchange
- the exchange to send- Returns:
- a handle to be used to get the response in the future
-
asyncSend
Sends an asynchronous exchange to the given endpoint. Important: The transformer processor is invoked by a thread from the underlying thread pool, when the task is running to send the exchange asynchronously. In other words mind about thread-safety when using the transformer processor.- Parameters:
endpoint
- the endpoint to send the exchange toprocessor
- the transformer used to populate the new exchange- Returns:
- a handle to be used to get the response in the future
-
asyncSendBody
Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOnly
message exchange pattern.- Parameters:
endpoint
- the endpoint to send the exchange tobody
- the body to send- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBody
Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpoint
- the endpoint to send the exchange tobody
- the body to send- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBodyAndHeader
CompletableFuture<Object> asyncRequestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue) Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpoint
- the endpoint to send the exchange tobody
- the body to sendheader
- the header nameheaderValue
- the header value- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBodyAndHeaders
CompletableFuture<Object> asyncRequestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers) Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpoint
- the endpoint to send the exchange tobody
- the body to sendheaders
- headers- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBody
Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpoint
- the endpoint to send the exchange tobody
- the body to sendtype
- the expected response type- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBodyAndHeader
<T> CompletableFuture<T> asyncRequestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type) Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpoint
- the endpoint to send the exchange tobody
- the body to sendheader
- the header nameheaderValue
- the header valuetype
- the expected response type- Returns:
- a handle to be used to get the response in the future
-
asyncRequestBodyAndHeaders
<T> CompletableFuture<T> asyncRequestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers, Class<T> type) Sends an asynchronous body to the given endpoint. Uses anExchangePattern.InOut
message exchange pattern.- Parameters:
endpoint
- the endpoint to send the exchange tobody
- the body to sendheaders
- headerstype
- the expected response type- Returns:
- a handle to be used to get the response in the future
-
extractFutureBody
Gets the response body from the future handle, will wait until the response is ready. Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
future
- the handle to get the responsetype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
CamelExecutionException
- if the processing of the exchange failed
-
extractFutureBody
<T> T extractFutureBody(Future<?> future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException, CamelExecutionException Gets the response body from the future handle, will wait at most the given time for the response to be ready. Notice: that if the processing of the exchange failed with an Exception it is thrown from this method as aCamelExecutionException
with the caused exception wrapped.- Parameters:
future
- the handle to get the responsetimeout
- the maximum time to waitunit
- the time unit of the timeout argumenttype
- the expected response type- Returns:
- the result (see class javadoc)
- Throws:
TimeoutException
- if the wait timed outCamelExecutionException
- if the processing of the exchange failed
-