Class AsyncMessageProcessor
- java.lang.Object
-
- com.swiftmq.swiftlet.queue.MessageProcessor
-
- com.swiftmq.impl.jms.standard.v400.AsyncMessageProcessor
-
- All Implemented Interfaces:
AsyncTask
,java.lang.Runnable
public class AsyncMessageProcessor extends MessageProcessor
-
-
Constructor Summary
Constructors Constructor Description AsyncMessageProcessor(Session session, SessionContext ctx, Consumer consumer, int consumerCacheSize, int recoveryEpoche)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getConsumerCacheSize()
java.lang.String
getDescription()
Returns a short description of this task.java.lang.String
getDispatchToken()
Returns the dispatch token of the task.boolean
isValid()
Returns whether the task is valid.void
processException(java.lang.Exception exception)
Process an exception.void
processMessage(MessageEntry messageEntry)
Process a message.void
processMessages(int numberMessages)
Process messages in bulk mode.void
reset()
Reset the MessageProcessor to its initial state without the need to recreate it.void
run()
Implements the task logic.void
setConsumerCacheSize(int consumerCacheSize)
void
stop()
Stops this task.-
Methods inherited from class com.swiftmq.swiftlet.queue.MessageProcessor
createBulkBuffer, getBulkBuffer, getCurrentBulkSize, getMaxBulkSize, getReceiverId, getRegistrationId, getRegistrationTime, getSelector, getTimeout, getTransactionId, getViewId, isAutoCommit, isBulkMode, setAutoCommit, setBulkMode, setCurrentBulkSize, setReceiverId, setRegistrationId, setRegistrationTime, setTransactionId, setViewId
-
-
-
-
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' onisValid()
to avoid execution.- Specified by:
stop
in interfaceAsyncTask
- Overrides:
stop
in classMessageProcessor
-
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 classMessageProcessor
-
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 withgetBulkBuffer()
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 therun()
method.- Overrides:
processMessages
in classMessageProcessor
- 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 therun()
method.- Specified by:
processMessage
in classMessageProcessor
- Parameters:
messageEntry
- message entry.
-
processException
public void processException(java.lang.Exception exception)
Description copied from class:MessageProcessor
Process an exception. A timeout is indicated by aQueueTimeoutException
.- Specified by:
processException
in classMessageProcessor
- Parameters:
exception
- exception.- See Also:
QueueTimeoutException
-
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 interfaceAsyncTask
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classMessageProcessor
-
getDescription
public java.lang.String getDescription()
Description copied from interface:AsyncTask
Returns a short description of this task. Used for trace outputs.- Specified by:
getDescription
in interfaceAsyncTask
- Overrides:
getDescription
in classMessageProcessor
- Returns:
- description.
-
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 invokingdispatchTask
of the ThreadpoolSwiftlet directly to determine the pool.- Specified by:
getDispatchToken
in interfaceAsyncTask
- Overrides:
getDispatchToken
in classMessageProcessor
- Returns:
- dispatch token.
-
-