Class ReplyManagerSupport
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.component.jms.reply.ReplyManagerSupport
-
- All Implemented Interfaces:
AutoCloseable
,ReplyManager
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
,org.springframework.jms.listener.SessionAwareMessageListener
- Direct Known Subclasses:
QueueReplyManager
,TemporaryQueueReplyManager
public abstract class ReplyManagerSupport extends org.apache.camel.support.service.ServiceSupport implements ReplyManager
Base class forReplyManager
implementations.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.camel.CamelContext
camelContext
protected org.apache.camel.component.jms.reply.CorrelationTimeoutMap
correlation
protected String
correlationProperty
protected JmsEndpoint
endpoint
protected ExecutorService
executorService
protected org.springframework.jms.listener.AbstractMessageListenerContainer
listenerContainer
protected org.slf4j.Logger
log
protected javax.jms.Destination
replyTo
protected CountDownLatch
replyToLatch
protected long
replyToTimeout
protected ScheduledExecutorService
scheduledExecutorService
-
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 protected abstract org.springframework.jms.listener.AbstractMessageListenerContainer
createListenerContainer()
protected abstract ReplyHandler
createReplyHandler(ReplyManager replyManager, org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback, String originalCorrelationId, String correlationId, long requestTimeout)
protected void
doStart()
protected void
doStop()
javax.jms.Destination
getReplyTo()
Gets the reply to queue being usedprotected abstract void
handleReplyMessage(String correlationID, javax.jms.Message message, javax.jms.Session session)
void
onMessage(javax.jms.Message message, javax.jms.Session session)
void
processReply(ReplyHolder holder)
Process the replyString
registerReply(ReplyManager replyManager, org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback, String originalCorrelationId, String correlationId, long requestTimeout)
Register a replyvoid
setCorrelationProperty(String correlationProperty)
Sets the JMS message property used for message correlation.void
setEndpoint(JmsEndpoint endpoint)
Sets the belongingJmsEndpoint
.void
setOnTimeoutExecutorService(ExecutorService executorService)
Sets the thread pool to use for continue routingExchange
when a timeout was triggered when doing request/reply over JMS.void
setReplyTo(javax.jms.Destination replyTo)
Sets the reply to queue the manager should listen for replies.void
setScheduledExecutorService(ScheduledExecutorService executorService)
Sets the scheduled thread pool to use when checking for timeouts (no reply received within a given time period)protected ReplyHandler
waitForProvisionCorrelationToBeUpdated(String correlationID, javax.jms.Message 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.jms.reply.ReplyManager
setReplyToSelectorHeader, updateCorrelationId
-
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
camelContext
protected final org.apache.camel.CamelContext camelContext
-
scheduledExecutorService
protected ScheduledExecutorService scheduledExecutorService
-
executorService
protected ExecutorService executorService
-
endpoint
protected JmsEndpoint endpoint
-
replyTo
protected javax.jms.Destination replyTo
-
listenerContainer
protected org.springframework.jms.listener.AbstractMessageListenerContainer listenerContainer
-
replyToLatch
protected final CountDownLatch replyToLatch
-
replyToTimeout
protected final long replyToTimeout
- See Also:
- Constant Field Values
-
correlation
protected org.apache.camel.component.jms.reply.CorrelationTimeoutMap correlation
-
correlationProperty
protected String correlationProperty
-
-
Method Detail
-
setScheduledExecutorService
public void setScheduledExecutorService(ScheduledExecutorService executorService)
Description copied from interface:ReplyManager
Sets the scheduled thread pool to use when checking for timeouts (no reply received within a given time period)- Specified by:
setScheduledExecutorService
in interfaceReplyManager
-
setOnTimeoutExecutorService
public void setOnTimeoutExecutorService(ExecutorService executorService)
Description copied from interface:ReplyManager
Sets the thread pool to use for continue routingExchange
when a timeout was triggered when doing request/reply over JMS.- Specified by:
setOnTimeoutExecutorService
in interfaceReplyManager
-
setEndpoint
public void setEndpoint(JmsEndpoint endpoint)
Description copied from interface:ReplyManager
Sets the belongingJmsEndpoint
.- Specified by:
setEndpoint
in interfaceReplyManager
-
setReplyTo
public void setReplyTo(javax.jms.Destination replyTo)
Description copied from interface:ReplyManager
Sets the reply to queue the manager should listen for replies. The queue is either a temporary or a persistent queue.- Specified by:
setReplyTo
in interfaceReplyManager
-
setCorrelationProperty
public void setCorrelationProperty(String correlationProperty)
Description copied from interface:ReplyManager
Sets the JMS message property used for message correlation. If set message correlation will be performed on the value of this JMS property, JMSCorrelationID will be ignored.- Specified by:
setCorrelationProperty
in interfaceReplyManager
-
getReplyTo
public javax.jms.Destination getReplyTo()
Description copied from interface:ReplyManager
Gets the reply to queue being used- Specified by:
getReplyTo
in 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:ReplyManager
Register a reply- Specified by:
registerReply
in 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)
-
onMessage
public void onMessage(javax.jms.Message message, javax.jms.Session session) throws javax.jms.JMSException
- Specified by:
onMessage
in interfaceorg.springframework.jms.listener.SessionAwareMessageListener
- Throws:
javax.jms.JMSException
-
processReply
public void processReply(ReplyHolder holder)
Description copied from interface:ReplyManager
Process the reply- Specified by:
processReply
in interfaceReplyManager
- Parameters:
holder
- containing needed data to process the reply and continue routing
-
handleReplyMessage
protected abstract void handleReplyMessage(String correlationID, javax.jms.Message message, javax.jms.Session session)
-
createListenerContainer
protected abstract org.springframework.jms.listener.AbstractMessageListenerContainer createListenerContainer() throws Exception
- Throws:
Exception
-
waitForProvisionCorrelationToBeUpdated
protected ReplyHandler waitForProvisionCorrelationToBeUpdated(String correlationID, javax.jms.Message 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:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
-