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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
doStart()
protected void
doStop()
org.apache.camel.CamelContext
abstract String
getRequestCorrelationId
(Object request) Implement this method to extract the correlation id from the request message body.abstract String
getResponseCorrelationId
(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.long
long
org.apache.camel.LoggingLevel
getTimeoutResponse
(String correlationId, Object request) Override this to implement a custom timeout response message.void
putState
(io.netty.channel.Channel channel, NettyCamelState state) Puts the state.void
removeState
(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel) Removes the state when the channel is inactive.void
setCamelContext
(org.apache.camel.CamelContext camelContext) void
setTimeout
(long timeout) Sets timeout value in millis seconds.void
setTimeoutChecker
(long timeoutChecker) Time in millis how frequent to check for timeouts.void
setTimeoutLoggingLevel
(org.apache.camel.LoggingLevel timeoutLoggingLevel) Sets the logging level to use when a timeout was hit.void
setWorkerPool
(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, 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.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods 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:
getCamelContext
in interfaceorg.apache.camel.spi.HasCamelContext
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContext
in 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
ExchangeTimedOutException
exception.
-
putState
Description copied from interface:NettyCamelStateCorrelationManager
Puts the state. You can get access to the Camel message from theNettyCamelState
instance.- Specified by:
putState
in 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:NettyCamelStateCorrelationManager
Removes the state when the channel is inactive.- Specified by:
removeState
in 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:NettyCamelStateCorrelationManager
Gets the state when a response message has been received. If the implementation stores the state temporary in for example aMap
instance 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:
getState
in 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:NettyCamelStateCorrelationManager
Gets the state when some internal error occurred.- Specified by:
getState
in interfaceNettyCamelStateCorrelationManager
- Parameters:
ctx
- netty channel handler contextchannel
- the channelcause
- the error
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doShutdown
- Overrides:
doShutdown
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-