Class AsyncMessageProcessor

    • Constructor Detail

      • AsyncMessageProcessor

        public AsyncMessageProcessor​(Session session,
                                     SessionContext ctx,
                                     Consumer consumer,
                                     int consumerCacheSize,
                                     int recoveryEpoche)
    • Method Detail

      • getConsumerCacheSize

        public int getConsumerCacheSize()
      • setConsumerCacheSize

        public void setConsumerCacheSize​(int consumerCacheSize)
      • isValid

        public boolean isValid()
        Description copied from interface: AsyncTask
        Returns whether the task is valid. This is application dependent. As long as a task stays in the thread pool queue, this state can change. If the task is going to execute, it will be checked whether the task is valid. If not, the task isn't executed anymore. For example, if a task depends on a connection and the connection closes before the task is executed, this method should return false which leads to drop the task out of the pool without executing it.
        Returns:
        true/false.
      • stop

        public void stop()
        Description copied from interface: AsyncTask
        Stops this task. This method doesn't stop the task's execution. It is implementation dependent in which state the task will turn. In most cases, the task does some clean up and returns 'false' on isValid() to avoid execution.
        Specified by:
        stop in interface AsyncTask
        Overrides:
        stop in class MessageProcessor
      • reset

        public void reset()
        Description copied from class: MessageProcessor
        Reset the MessageProcessor to its initial state without the need to recreate it.
        Overrides:
        reset in class MessageProcessor
      • processMessages

        public void processMessages​(int numberMessages)
        Description copied from class: MessageProcessor
        Process messages in bulk mode. Called when messages are available and the selector matches, if specified. The queue first obtains the bulk buffer with getBulkBuffer() and fills it with message entries up to the buffer size. It then calls this method and passes the actual number of messages in the buffer. Use this method to store the message and dispatch the MessageProcessor to a thread pool. Implement the processing itself inside the run() method.
        Overrides:
        processMessages in class MessageProcessor
        Parameters:
        numberMessages - number Messages in bulk buffer.
      • processMessage

        public void processMessage​(MessageEntry messageEntry)
        Description copied from class: MessageProcessor
        Process a message. Called when a message is available and the selector matches, if specified. Use this method to store the message and dispatch the MessageProcessor to a thread pool. Implement the processing itself inside the run() method.
        Specified by:
        processMessage in class MessageProcessor
        Parameters:
        messageEntry - message entry.
      • register

        public void register()
      • run

        public void run()
        Description copied from interface: AsyncTask
        Implements the task logic. This method will be called when a task is executed from a pool thread.
        Specified by:
        run in interface AsyncTask
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class MessageProcessor
      • getDispatchToken

        public java.lang.String getDispatchToken()
        Description copied from interface: AsyncTask
        Returns the dispatch token of the task. The dispatch token is the thread name, used for thread assignment in the router's configuration file. It is used to determine the pool by invoking dispatchTask of the ThreadpoolSwiftlet directly to determine the pool.
        Specified by:
        getDispatchToken in interface AsyncTask
        Overrides:
        getDispatchToken in class MessageProcessor
        Returns:
        dispatch token.