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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    protected void
     
    org.apache.camel.CamelContext
     
    abstract String
    Implement this method to extract the correlation id from the request message body.
    abstract String
    Implement this method to extract the correlation id from the response message body.
    getState(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel, Object msg)
    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
    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 interface org.apache.camel.spi.HasCamelContext
    • setCamelContext

      public void setCamelContext(org.apache.camel.CamelContext camelContext)
      Specified by:
      setCamelContext in interface org.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

      public ExecutorService getWorkerPool()
    • setWorkerPool

      public void setWorkerPool(ExecutorService workerPool)
      To use a shared worker pool for processing timed out requests.
    • getRequestCorrelationId

      public abstract String getRequestCorrelationId(Object request)
      Implement this method to extract the correlation id from the request message body.
    • getResponseCorrelationId

      public abstract String getResponseCorrelationId(Object response)
      Implement this method to extract the correlation id from the response message body.
    • getTimeoutResponse

      public String getTimeoutResponse(String correlationId, Object request)
      Override this to implement a custom timeout response message.
      Parameters:
      correlationId - the correlation id
      request - the request message
      Returns:
      the response message or null to use an ExchangeTimedOutException exception.
    • putState

      public void putState(io.netty.channel.Channel channel, NettyCamelState state)
      Description copied from interface: NettyCamelStateCorrelationManager
      Puts the state.

      You can get access to the Camel message from the NettyCamelState instance.

      Specified by:
      putState in interface NettyCamelStateCorrelationManager
      Parameters:
      channel - the channel
      state - 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 interface NettyCamelStateCorrelationManager
      Parameters:
      ctx - netty channel handler context
      channel - 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 a Map instance then this method should remove the state from the map as its no longer needed. In other words use the Map.remove(Object) to get and remove the state.

      Specified by:
      getState in interface NettyCamelStateCorrelationManager
      Parameters:
      ctx - netty channel handler context
      channel - the channel
      msg - 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 interface NettyCamelStateCorrelationManager
      Parameters:
      ctx - netty channel handler context
      channel - the channel
      cause - the error
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doShutdown

      protected void doShutdown() throws Exception
      Overrides:
      doShutdown in class org.apache.camel.support.service.BaseService
      Throws:
      Exception