Class ReplyManagerSupport
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.component.rabbitmq.reply.ReplyManagerSupport
-
- All Implemented Interfaces:
AutoCloseable,ReplyManager,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
- Direct Known Subclasses:
TemporaryQueueReplyManager
public abstract class ReplyManagerSupport extends org.apache.camel.support.service.ServiceSupport implements ReplyManager
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.camel.CamelContextcamelContextprotected org.apache.camel.TimeoutMap<String,ReplyHandler>correlationprotected RabbitMQEndpointendpointprotected ScheduledExecutorServiceexecutorServiceprotected com.rabbitmq.client.ConnectionlistenerContainerprotected StringreplyToprotected CountDownLatchreplyToLatchprotected longreplyToTimeout
-
Constructor Summary
Constructors Constructor Description ReplyManagerSupport(org.apache.camel.CamelContext camelContext)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcancelCorrelationId(String correlationId)Unregister a correlationId when you no longer need a replyprotected abstract com.rabbitmq.client.ConnectioncreateListenerContainer()protected abstract ReplyHandlercreateReplyHandler(ReplyManager replyManager, org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback, String originalCorrelationId, String correlationId, long requestTimeout)protected voiddoStart()protected voiddoStop()StringgetReplyTo()Gets the reply to queue being usedprotected abstract voidhandleReplyMessage(String correlationID, com.rabbitmq.client.AMQP.BasicProperties properties, byte[] message)voidonMessage(com.rabbitmq.client.AMQP.BasicProperties properties, byte[] message)voidprocessReply(ReplyHolder holder)Process the replyStringregisterReply(ReplyManager replyManager, org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback, String originalCorrelationId, String correlationId, long requestTimeout)Register a replyvoidsetEndpoint(RabbitMQEndpoint endpoint)Sets the belongingRabbitMQEndpointvoidsetReplyTo(String replyTo)Sets the reply to queue the manager should listen for replies.voidsetScheduledExecutorService(ScheduledExecutorService executorService)Sets the scheduled to use when checking for timeouts (no reply received within a given time period)protected ReplyHandlerwaitForProvisionCorrelationToBeUpdated(String correlationID, byte[] message)IMPORTANT: This logic is only being used due to high performance in-memory only testing using InOut over JMS.-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, 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.component.rabbitmq.reply.ReplyManager
updateCorrelationId
-
-
-
-
Field Detail
-
camelContext
protected final org.apache.camel.CamelContext camelContext
-
replyToLatch
protected final CountDownLatch replyToLatch
-
replyToTimeout
protected final long replyToTimeout
- See Also:
- Constant Field Values
-
executorService
protected ScheduledExecutorService executorService
-
endpoint
protected RabbitMQEndpoint endpoint
-
replyTo
protected String replyTo
-
listenerContainer
protected com.rabbitmq.client.Connection listenerContainer
-
correlation
protected org.apache.camel.TimeoutMap<String,ReplyHandler> correlation
-
-
Method Detail
-
setScheduledExecutorService
public void setScheduledExecutorService(ScheduledExecutorService executorService)
Description copied from interface:ReplyManagerSets the scheduled to use when checking for timeouts (no reply received within a given time period)- Specified by:
setScheduledExecutorServicein interfaceReplyManager
-
setEndpoint
public void setEndpoint(RabbitMQEndpoint endpoint)
Description copied from interface:ReplyManagerSets the belongingRabbitMQEndpoint- Specified by:
setEndpointin interfaceReplyManager
-
setReplyTo
public void setReplyTo(String replyTo)
Description copied from interface:ReplyManagerSets the reply to queue the manager should listen for replies. The queue is either a temporary or a persistent queue.- Specified by:
setReplyToin interfaceReplyManager
-
getReplyTo
public String getReplyTo()
Description copied from interface:ReplyManagerGets the reply to queue being used- Specified by:
getReplyToin interfaceReplyManager
-
registerReply
public String registerReply(ReplyManager replyManager, org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback, String originalCorrelationId, String correlationId, long requestTimeout)
Description copied from interface:ReplyManagerRegister a reply- Specified by:
registerReplyin interfaceReplyManager- Parameters:
replyManager- the reply manager being usedexchange- the exchangecallback- the callbackoriginalCorrelationId- an optional original correlation idcorrelationId- the correlation id to expect being usedrequestTimeout- the timeout- Returns:
- the correlation id used
-
createReplyHandler
protected abstract ReplyHandler createReplyHandler(ReplyManager replyManager, org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback, String originalCorrelationId, String correlationId, long requestTimeout)
-
cancelCorrelationId
public void cancelCorrelationId(String correlationId)
Description copied from interface:ReplyManagerUnregister a correlationId when you no longer need a reply- Specified by:
cancelCorrelationIdin interfaceReplyManager
-
onMessage
public void onMessage(com.rabbitmq.client.AMQP.BasicProperties properties, byte[] message)
-
processReply
public void processReply(ReplyHolder holder)
Description copied from interface:ReplyManagerProcess the reply- Specified by:
processReplyin interfaceReplyManager- Parameters:
holder- containing needed data to process the reply and continue routing
-
handleReplyMessage
protected abstract void handleReplyMessage(String correlationID, com.rabbitmq.client.AMQP.BasicProperties properties, byte[] message)
-
createListenerContainer
protected abstract com.rabbitmq.client.Connection createListenerContainer() throws Exception- Throws:
Exception
-
waitForProvisionCorrelationToBeUpdated
protected ReplyHandler waitForProvisionCorrelationToBeUpdated(String correlationID, byte[] message)
IMPORTANT: This logic is only being used due to high performance in-memory only testing using InOut over JMS. Its unlikely to happen in a real life situation with communication to a remote broker, which always will be slower to send back reply, before Camel had a chance to update it's internal correlation map.
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
-