Class TimeoutCorrelationManagerSupport

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

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doShutdown()  
      protected void doStart()  
      protected void doStop()  
      org.apache.camel.CamelContext getCamelContext()  
      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.
      NettyCamelState getState​(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel, Object msg)
      Gets the state when a response message has been received.
      NettyCamelState getState​(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.Channel channel, Throwable cause)
      Gets the state when some internal error occurred.
      long getTimeout()  
      long getTimeoutChecker()  
      org.apache.camel.LoggingLevel getTimeoutLoggingLevel()  
      String getTimeoutResponse​(String correlationId, Object request)
      Override this to implement a custom timeout response message.
      ExecutorService getWorkerPool()  
      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 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 Detail

      • TimeoutCorrelationManagerSupport

        public TimeoutCorrelationManagerSupport()
    • Method Detail

      • getCamelContext

        public org.apache.camel.CamelContext getCamelContext()
        Specified by:
        getCamelContext in interface org.apache.camel.CamelContextAware
      • 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.
      • 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.
      • 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
      • 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