public class DefaultConsumerTemplate extends ServiceSupport implements ConsumerTemplate
Message instances in an
Exchange from an Endpoint.shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Constructor and Description |
|---|
DefaultConsumerTemplate(CamelContext camelContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
doneUoW(Exchange exchange)
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
protected Object |
extractResultBody(Exchange result)
Extracts the body from the given result.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
CamelContext |
getContext()
Deprecated.
|
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
ConsumerTemplate.doneUoW(Exchange) |
Exchange |
receive(String endpointUri)
Receives from the endpoint, waiting until there is a response
Important: See
ConsumerTemplate.doneUoW(Exchange) |
Exchange |
receive(String endpointUri,
long timeout)
Receives from the endpoint, waiting until there is a response
or the timeout occurs
Important: See
ConsumerTemplate.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.
|
protected Endpoint |
resolveMandatoryEndpoint(String endpointUri) |
void |
setMaximumCacheSize(int maximumCacheSize)
Sets a custom maximum cache size.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspendpublic DefaultConsumerTemplate(CamelContext camelContext)
public int getMaximumCacheSize()
ConsumerTemplategetMaximumCacheSize in interface ConsumerTemplatepublic void setMaximumCacheSize(int maximumCacheSize)
ConsumerTemplatesetMaximumCacheSize in interface ConsumerTemplatemaximumCacheSize - the custom maximum cache sizepublic int getCurrentCacheSize()
ConsumerTemplategetCurrentCacheSize in interface ConsumerTemplate@Deprecated public CamelContext getContext()
getCamelContext()public CamelContext getCamelContext()
ConsumerTemplateCamelContextgetCamelContext in interface ConsumerTemplatepublic Exchange receive(String endpointUri)
ConsumerTemplateConsumerTemplate.doneUoW(Exchange)receive in interface ConsumerTemplateendpointUri - the endpoint to receive frompublic Exchange receive(Endpoint endpoint)
ConsumerTemplateConsumerTemplate.doneUoW(Exchange)receive in interface ConsumerTemplateendpoint - the endpoint to receive fromConsumerTemplate.doneUoW(Exchange)public Exchange receive(String endpointUri, long timeout)
ConsumerTemplateConsumerTemplate.doneUoW(Exchange)receive in interface ConsumerTemplateendpointUri - the endpoint to receive fromtimeout - timeout in millis to wait for a responseConsumerTemplate.doneUoW(Exchange)public Exchange receive(Endpoint endpoint, long timeout)
ConsumerTemplateConsumerTemplate.doneUoW(Exchange)receive in interface ConsumerTemplateendpoint - the endpoint to receive fromtimeout - timeout in millis to wait for a responseConsumerTemplate.doneUoW(Exchange)public Exchange receiveNoWait(String endpointUri)
ConsumerTemplateConsumerTemplate.doneUoW(Exchange)receiveNoWait in interface ConsumerTemplateendpointUri - the endpoint to receive frompublic Exchange receiveNoWait(Endpoint endpoint)
ConsumerTemplateConsumerTemplate.doneUoW(Exchange)receiveNoWait in interface ConsumerTemplateendpoint - the endpoint to receive frompublic Object receiveBody(String endpointUri)
ConsumerTemplatereceiveBody in interface ConsumerTemplateendpointUri - the endpoint to receive frompublic Object receiveBody(Endpoint endpoint)
ConsumerTemplatereceiveBody in interface ConsumerTemplateendpoint - the endpoint to receive frompublic Object receiveBody(String endpointUri, long timeout)
ConsumerTemplatereceiveBody in interface ConsumerTemplateendpointUri - the endpoint to receive fromtimeout - timeout in millis to wait for a responsepublic Object receiveBody(Endpoint endpoint, long timeout)
ConsumerTemplatereceiveBody in interface ConsumerTemplateendpoint - the endpoint to receive fromtimeout - timeout in millis to wait for a responsepublic Object receiveBodyNoWait(String endpointUri)
ConsumerTemplatereceiveBodyNoWait in interface ConsumerTemplateendpointUri - the endpoint to receive frompublic Object receiveBodyNoWait(Endpoint endpoint)
ConsumerTemplatereceiveBodyNoWait in interface ConsumerTemplateendpoint - the endpoint to receive frompublic <T> T receiveBody(String endpointUri, Class<T> type)
ConsumerTemplatereceiveBody in interface ConsumerTemplateendpointUri - the endpoint to receive fromtype - the expected response typepublic <T> T receiveBody(Endpoint endpoint, Class<T> type)
ConsumerTemplatereceiveBody in interface ConsumerTemplateendpoint - the endpoint to receive fromtype - the expected response typepublic <T> T receiveBody(String endpointUri, long timeout, Class<T> type)
ConsumerTemplatereceiveBody in interface ConsumerTemplateendpointUri - the endpoint to receive fromtimeout - timeout in millis to wait for a responsetype - the expected response typepublic <T> T receiveBody(Endpoint endpoint, long timeout, Class<T> type)
ConsumerTemplatereceiveBody in interface ConsumerTemplateendpoint - the endpoint to receive fromtimeout - timeout in millis to wait for a responsetype - the expected response typepublic <T> T receiveBodyNoWait(String endpointUri, Class<T> type)
ConsumerTemplatereceiveBodyNoWait in interface ConsumerTemplateendpointUri - the endpoint to receive fromtype - the expected response typepublic <T> T receiveBodyNoWait(Endpoint endpoint, Class<T> type)
ConsumerTemplatereceiveBodyNoWait in interface ConsumerTemplateendpoint - the endpoint to receive fromtype - the expected response typepublic void doneUoW(Exchange exchange)
ConsumerTemplateExchange 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.doneUoW in interface ConsumerTemplateexchange - the exchangeprotected Endpoint resolveMandatoryEndpoint(String endpointUri)
protected Object extractResultBody(Exchange result)
result - the resultprotected 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