Package org.apache.camel.component.netty
Class TimeoutCorrelationManagerSupport
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.component.netty.TimeoutCorrelationManagerSupport
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,NettyCamelStateCorrelationManager,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HasCamelContext,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
public abstract class TimeoutCorrelationManagerSupport
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.CamelContextAware, NettyCamelStateCorrelationManager
A base class for using
NettyCamelStateCorrelationManager that supports timeout.-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voiddoStart()protected voiddoStop()org.apache.camel.CamelContextabstract StringgetRequestCorrelationId(Object request) Implement this method to extract the correlation id from the request message body.abstract StringgetResponseCorrelationId(Object response) Implement this method to extract the correlation id from the response message body.Gets the state when a response message has been received.getState(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel, Throwable cause) Gets the state when some internal error occurred.longlongorg.apache.camel.LoggingLevelgetTimeoutResponse(String correlationId, Object request) Override this to implement a custom timeout response message.voidputState(io.netty.channel.Channel channel, NettyCamelState state) Puts the state.voidremoveState(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel) Removes the state when the channel is inactive.voidsetCamelContext(org.apache.camel.CamelContext camelContext) voidsetTimeout(long timeout) Sets timeout value in millis seconds.voidsetTimeoutChecker(long timeoutChecker) Time in millis how frequent to check for timeouts.voidsetTimeoutLoggingLevel(org.apache.camel.LoggingLevel timeoutLoggingLevel) Sets the logging level to use when a timeout was hit.voidsetWorkerPool(ExecutorService workerPool) To use a shared worker pool for processing timed out requests.Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
TimeoutCorrelationManagerSupport
public TimeoutCorrelationManagerSupport()
-
-
Method Details
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContextin interfaceorg.apache.camel.spi.HasCamelContext
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getTimeout
public long getTimeout() -
setTimeout
public void setTimeout(long timeout) Sets timeout value in millis seconds. The default value is 30000 (30 seconds). -
getTimeoutChecker
public long getTimeoutChecker() -
setTimeoutChecker
public void setTimeoutChecker(long timeoutChecker) Time in millis how frequent to check for timeouts. Set this to a lower value if you want to react faster upon timeouts. The default value is 1000. -
getTimeoutLoggingLevel
public org.apache.camel.LoggingLevel getTimeoutLoggingLevel() -
setTimeoutLoggingLevel
public void setTimeoutLoggingLevel(org.apache.camel.LoggingLevel timeoutLoggingLevel) Sets the logging level to use when a timeout was hit. -
getWorkerPool
-
setWorkerPool
To use a shared worker pool for processing timed out requests. -
getRequestCorrelationId
Implement this method to extract the correlation id from the request message body. -
getResponseCorrelationId
Implement this method to extract the correlation id from the response message body. -
getTimeoutResponse
Override this to implement a custom timeout response message.- Parameters:
correlationId- the correlation idrequest- the request message- Returns:
- the response message or null to use an
ExchangeTimedOutExceptionexception.
-
putState
Description copied from interface:NettyCamelStateCorrelationManagerPuts the state. You can get access to the Camel message from theNettyCamelStateinstance.- Specified by:
putStatein interfaceNettyCamelStateCorrelationManager- Parameters:
channel- the channelstate- the Camel state to be stored
-
removeState
public void removeState(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel) Description copied from interface:NettyCamelStateCorrelationManagerRemoves the state when the channel is inactive.- Specified by:
removeStatein interfaceNettyCamelStateCorrelationManager- Parameters:
ctx- netty channel handler contextchannel- the channel
-
getState
public NettyCamelState getState(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel, Object msg) Description copied from interface:NettyCamelStateCorrelationManagerGets the state when a response message has been received. If the implementation stores the state temporary in for example aMapinstance then this method should remove the state from the map as its no longer needed. In other words use theMap.remove(Object)to get and remove the state.- Specified by:
getStatein interfaceNettyCamelStateCorrelationManager- Parameters:
ctx- netty channel handler contextchannel- the channelmsg- the response message
-
getState
public NettyCamelState getState(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel, Throwable cause) Description copied from interface:NettyCamelStateCorrelationManagerGets the state when some internal error occurred.- Specified by:
getStatein interfaceNettyCamelStateCorrelationManager- Parameters:
ctx- netty channel handler contextchannel- the channelcause- the error
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doShutdown
- Overrides:
doShutdownin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-