public interface ConsumerTemplate extends Service
Message
instances in an Exchange
from an
Endpoint
. ConsumerTemplate
is thread safe. RuntimeCamelException
if consuming of the Exchange
failed and an Exception
occurred. The getCause method on RuntimeCamelException
returns the wrapper original caused
exception. RuntimeCamelException
as stated aboveService.stop()
the template. ConsumerTemplate
as well.ProducerTemplate
,
FluentProducerTemplate
Modifier and Type | Method and Description |
---|---|
void |
cleanUp()
Cleanup the cache (purging stale entries)
|
void |
doneUoW(Exchange exchange)
|
CamelContext |
getCamelContext()
Get the
CamelContext |
int |
getCurrentCacheSize()
Gets an approximated size of the current cached resources in the backing cache pools.
|
int |
getMaximumCacheSize()
Gets the maximum cache size used.
|
Exchange |
receive(Endpoint endpoint)
Receives from the endpoint, waiting until there is a response.
|
Exchange |
receive(Endpoint endpoint,
long timeout)
Receives from the endpoint, waiting until there is a response or the timeout occurs
Important: See
doneUoW(Exchange) |
Exchange |
receive(String endpointUri)
Receives from the endpoint, waiting until there is a response
Important: See
doneUoW(Exchange) |
Exchange |
receive(String endpointUri,
long timeout)
Receives from the endpoint, waiting until there is a response or the timeout occurs
Important: See
doneUoW(Exchange) |
Object |
receiveBody(Endpoint endpoint)
Receives from the endpoint, waiting until there is a response
|
<T> T |
receiveBody(Endpoint endpoint,
Class<T> type)
Receives from the endpoint, waiting until there is a response
|
Object |
receiveBody(Endpoint endpoint,
long timeout)
Receives from the endpoint, waiting until there is a response or the timeout occurs
|
<T> T |
receiveBody(Endpoint endpoint,
long timeout,
Class<T> type)
Receives from the endpoint, waiting until there is a response or the timeout occurs
|
Object |
receiveBody(String endpointUri)
Receives from the endpoint, waiting until there is a response
|
<T> T |
receiveBody(String endpointUri,
Class<T> type)
Receives from the endpoint, waiting until there is a response
|
Object |
receiveBody(String endpointUri,
long timeout)
Receives from the endpoint, waiting until there is a response or the timeout occurs
|
<T> T |
receiveBody(String endpointUri,
long timeout,
Class<T> type)
Receives from the endpoint, waiting until there is a response or the timeout occurs
|
Object |
receiveBodyNoWait(Endpoint endpoint)
Receives from the endpoint, not waiting for a response if non exists.
|
<T> T |
receiveBodyNoWait(Endpoint endpoint,
Class<T> type)
Receives from the endpoint, not waiting for a response if non exists.
|
Object |
receiveBodyNoWait(String endpointUri)
Receives from the endpoint, not waiting for a response if non exists.
|
<T> T |
receiveBodyNoWait(String endpointUri,
Class<T> type)
Receives from the endpoint, not waiting for a response if non exists.
|
Exchange |
receiveNoWait(Endpoint endpoint)
Receives from the endpoint, not waiting for a response if non exists.
|
Exchange |
receiveNoWait(String endpointUri)
Receives from the endpoint, not waiting for a response if non exists.
|
void |
setMaximumCacheSize(int maximumCacheSize)
Sets a custom maximum cache size.
|
CamelContext getCamelContext()
CamelContext
int getMaximumCacheSize()
void setMaximumCacheSize(int maximumCacheSize)
maximumCacheSize
- the custom maximum cache sizeint getCurrentCacheSize()
void cleanUp()
Exchange receive(String endpointUri)
doneUoW(Exchange)
endpointUri
- the endpoint to receive fromExchange receive(Endpoint endpoint)
doneUoW(Exchange)
endpoint
- the endpoint to receive fromdoneUoW(Exchange)
Exchange receive(String endpointUri, long timeout)
doneUoW(Exchange)
endpointUri
- the endpoint to receive fromtimeout
- timeout in millis to wait for a responsedoneUoW(Exchange)
Exchange receive(Endpoint endpoint, long timeout)
doneUoW(Exchange)
endpoint
- the endpoint to receive fromtimeout
- timeout in millis to wait for a responsedoneUoW(Exchange)
Exchange receiveNoWait(String endpointUri)
doneUoW(Exchange)
endpointUri
- the endpoint to receive fromExchange receiveNoWait(Endpoint endpoint)
doneUoW(Exchange)
endpoint
- the endpoint to receive fromObject receiveBody(String endpointUri)
endpointUri
- the endpoint to receive fromObject receiveBody(Endpoint endpoint)
endpoint
- the endpoint to receive fromObject receiveBody(String endpointUri, long timeout)
endpointUri
- the endpoint to receive fromtimeout
- timeout in millis to wait for a responseObject receiveBody(Endpoint endpoint, long timeout)
endpoint
- the endpoint to receive fromtimeout
- timeout in millis to wait for a responseObject receiveBodyNoWait(String endpointUri)
endpointUri
- the endpoint to receive fromObject receiveBodyNoWait(Endpoint endpoint)
endpoint
- the endpoint to receive from<T> T receiveBody(String endpointUri, Class<T> type)
endpointUri
- the endpoint to receive fromtype
- the expected response type<T> T receiveBody(Endpoint endpoint, Class<T> type)
endpoint
- the endpoint to receive fromtype
- the expected response type<T> T receiveBody(String endpointUri, long timeout, Class<T> type)
endpointUri
- the endpoint to receive fromtimeout
- timeout in millis to wait for a responsetype
- the expected response type<T> T receiveBody(Endpoint endpoint, long timeout, Class<T> type)
endpoint
- the endpoint to receive fromtimeout
- timeout in millis to wait for a responsetype
- the expected response type<T> T receiveBodyNoWait(String endpointUri, Class<T> type)
endpointUri
- the endpoint to receive fromtype
- the expected response type<T> T receiveBodyNoWait(Endpoint endpoint, Class<T> type)
endpoint
- the endpoint to receive fromtype
- the expected response typevoid doneUoW(Exchange exchange)
Exchange
type then you need to
invoke this method when you are done using the returned Exchange
.
This is needed to ensure any Synchronization
works is being executed. For example if
you consumed from a file endpoint, then the consumed file is only moved/delete when you done the
Exchange
.
Note for all the other receive methods which does not return a Exchange
type, the done
has been executed automatic by Camel itself.exchange
- the exchangeApache Camel