|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.camel.impl.ServiceSupport
org.apache.camel.impl.DefaultConsumerTemplate
public class DefaultConsumerTemplate
Template (named like Spring's TransactionTemplate & JmsTemplate
et al) for working with Camel and consuming Message
instances in an
Exchange
from an Endpoint
.
Constructor Summary | |
---|---|
DefaultConsumerTemplate(CamelContext context)
|
Method Summary | ||
---|---|---|
void |
doneUoW(Exchange exchange)
If you have used any of the receive methods which returns a Exchange type
then you need to invoke this method when you are done using the returned Exchange . |
|
protected void |
doStart()
|
|
protected void |
doStop()
|
|
protected java.lang.Object |
extractResultBody(Exchange result)
Extracts the body from the given result. |
|
CamelContext |
getCamelContext()
|
|
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(java.lang.String endpointUri)
Receives from the endpoint, waiting until there is a response Important: See ConsumerTemplate.doneUoW(Exchange) |
|
Exchange |
receive(java.lang.String endpointUri,
long timeout)
Receives from the endpoint, waiting until there is a response or the timeout occurs Important: See ConsumerTemplate.doneUoW(Exchange) |
|
java.lang.Object |
receiveBody(Endpoint endpoint)
Receives from the endpoint, waiting until there is a response |
|
|
receiveBody(Endpoint endpoint,
java.lang.Class<T> type)
Receives from the endpoint, waiting until there is a response |
|
java.lang.Object |
receiveBody(Endpoint endpoint,
long timeout)
Receives from the endpoint, waiting until there is a response or the timeout occurs |
|
|
receiveBody(Endpoint endpoint,
long timeout,
java.lang.Class<T> type)
Receives from the endpoint, waiting until there is a response or the timeout occurs |
|
java.lang.Object |
receiveBody(java.lang.String endpointUri)
Receives from the endpoint, waiting until there is a response |
|
|
receiveBody(java.lang.String endpointUri,
java.lang.Class<T> type)
Receives from the endpoint, waiting until there is a response |
|
java.lang.Object |
receiveBody(java.lang.String endpointUri,
long timeout)
Receives from the endpoint, waiting until there is a response or the timeout occurs |
|
|
receiveBody(java.lang.String endpointUri,
long timeout,
java.lang.Class<T> type)
Receives from the endpoint, waiting until there is a response or the timeout occurs |
|
java.lang.Object |
receiveBodyNoWait(Endpoint endpoint)
Receives from the endpoint, not waiting for a response if non exists. |
|
|
receiveBodyNoWait(Endpoint endpoint,
java.lang.Class<T> type)
Receives from the endpoint, not waiting for a response if non exists. |
|
java.lang.Object |
receiveBodyNoWait(java.lang.String endpointUri)
Receives from the endpoint, not waiting for a response if non exists. |
|
|
receiveBodyNoWait(java.lang.String endpointUri,
java.lang.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(java.lang.String endpointUri)
Receives from the endpoint, not waiting for a response if non exists. |
|
protected Endpoint |
resolveMandatoryEndpoint(java.lang.String endpointUri)
|
|
void |
setMaximumCacheSize(int maximumCacheSize)
Sets a custom maximum cache size. |
Methods inherited from class org.apache.camel.impl.ServiceSupport |
---|
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.camel.Service |
---|
start, stop |
Constructor Detail |
---|
public DefaultConsumerTemplate(CamelContext context)
Method Detail |
---|
public int getMaximumCacheSize()
ConsumerTemplate
getMaximumCacheSize
in interface ConsumerTemplate
public void setMaximumCacheSize(int maximumCacheSize)
ConsumerTemplate
setMaximumCacheSize
in interface ConsumerTemplate
maximumCacheSize
- the custom maximum cache sizepublic int getCurrentCacheSize()
ConsumerTemplate
getCurrentCacheSize
in interface ConsumerTemplate
public CamelContext getCamelContext()
public Exchange receive(java.lang.String endpointUri)
ConsumerTemplate
ConsumerTemplate.doneUoW(Exchange)
receive
in interface ConsumerTemplate
endpointUri
- the endpoint to receive from
public Exchange receive(Endpoint endpoint)
ConsumerTemplate
ConsumerTemplate.doneUoW(Exchange)
receive
in interface ConsumerTemplate
endpoint
- the endpoint to receive from
ConsumerTemplate.doneUoW(Exchange)
public Exchange receive(java.lang.String endpointUri, long timeout)
ConsumerTemplate
ConsumerTemplate.doneUoW(Exchange)
receive
in interface ConsumerTemplate
endpointUri
- the endpoint to receive fromtimeout
- timeout in millis to wait for a response
ConsumerTemplate.doneUoW(Exchange)
public Exchange receive(Endpoint endpoint, long timeout)
ConsumerTemplate
ConsumerTemplate.doneUoW(Exchange)
receive
in interface ConsumerTemplate
endpoint
- the endpoint to receive fromtimeout
- timeout in millis to wait for a response
ConsumerTemplate.doneUoW(Exchange)
public Exchange receiveNoWait(java.lang.String endpointUri)
ConsumerTemplate
ConsumerTemplate.doneUoW(Exchange)
receiveNoWait
in interface ConsumerTemplate
endpointUri
- the endpoint to receive from
public Exchange receiveNoWait(Endpoint endpoint)
ConsumerTemplate
ConsumerTemplate.doneUoW(Exchange)
receiveNoWait
in interface ConsumerTemplate
endpoint
- the endpoint to receive from
public java.lang.Object receiveBody(java.lang.String endpointUri)
ConsumerTemplate
receiveBody
in interface ConsumerTemplate
endpointUri
- the endpoint to receive from
public java.lang.Object receiveBody(Endpoint endpoint)
ConsumerTemplate
receiveBody
in interface ConsumerTemplate
endpoint
- the endpoint to receive from
public java.lang.Object receiveBody(java.lang.String endpointUri, long timeout)
ConsumerTemplate
receiveBody
in interface ConsumerTemplate
endpointUri
- the endpoint to receive fromtimeout
- timeout in millis to wait for a response
public java.lang.Object receiveBody(Endpoint endpoint, long timeout)
ConsumerTemplate
receiveBody
in interface ConsumerTemplate
endpoint
- the endpoint to receive fromtimeout
- timeout in millis to wait for a response
public java.lang.Object receiveBodyNoWait(java.lang.String endpointUri)
ConsumerTemplate
receiveBodyNoWait
in interface ConsumerTemplate
endpointUri
- the endpoint to receive from
public java.lang.Object receiveBodyNoWait(Endpoint endpoint)
ConsumerTemplate
receiveBodyNoWait
in interface ConsumerTemplate
endpoint
- the endpoint to receive from
public <T> T receiveBody(java.lang.String endpointUri, java.lang.Class<T> type)
ConsumerTemplate
receiveBody
in interface ConsumerTemplate
endpointUri
- the endpoint to receive fromtype
- the expected response type
public <T> T receiveBody(Endpoint endpoint, java.lang.Class<T> type)
ConsumerTemplate
receiveBody
in interface ConsumerTemplate
endpoint
- the endpoint to receive fromtype
- the expected response type
public <T> T receiveBody(java.lang.String endpointUri, long timeout, java.lang.Class<T> type)
ConsumerTemplate
receiveBody
in interface ConsumerTemplate
endpointUri
- the endpoint to receive fromtimeout
- timeout in millis to wait for a responsetype
- the expected response type
public <T> T receiveBody(Endpoint endpoint, long timeout, java.lang.Class<T> type)
ConsumerTemplate
receiveBody
in interface ConsumerTemplate
endpoint
- the endpoint to receive fromtimeout
- timeout in millis to wait for a responsetype
- the expected response type
public <T> T receiveBodyNoWait(java.lang.String endpointUri, java.lang.Class<T> type)
ConsumerTemplate
receiveBodyNoWait
in interface ConsumerTemplate
endpointUri
- the endpoint to receive fromtype
- the expected response type
public <T> T receiveBodyNoWait(Endpoint endpoint, java.lang.Class<T> type)
ConsumerTemplate
receiveBodyNoWait
in interface ConsumerTemplate
endpoint
- the endpoint to receive fromtype
- the expected response type
public void doneUoW(Exchange exchange)
ConsumerTemplate
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.
doneUoW
in interface ConsumerTemplate
exchange
- the exchangeprotected Endpoint resolveMandatoryEndpoint(java.lang.String endpointUri)
protected java.lang.Object extractResultBody(Exchange result)
result
- the result
protected void doStart() throws java.lang.Exception
doStart
in class ServiceSupport
java.lang.Exception
protected void doStop() throws java.lang.Exception
doStop
in class ServiceSupport
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |