class MessageProcessingTask extends Object implements Runnable
ExecutorService
.
To reduce memory allocation this class is designed to be suitable for
usage with pooling, the instance of this type is mutable such that
RawMessage can be updated and instance can be reused and
scheduled with new RawMessageModifier and Type | Field and Description |
---|---|
private AtomicBoolean |
cancelled
Indicates that MessageProcessingTask is cancelled and should not
process RawMessage anymore.
|
private ErrorHandler |
errorHandler
The listener that will be collecting error notifications.
|
private static Logger |
logger
Our class logger.
|
private MessageEventHandler |
messageEventHandler
The listener that will be retrieving MessageEvents
|
private NetAccessManager |
netAccessManager
The NetAccessManager which has created this instance and which
is its owner.
|
private RawMessage |
rawMessage
Raw message which is being processed
|
private Consumer<MessageProcessingTask> |
rawMessageProcessedHandler
Callback which is invoked when this MessageProcessingTask
processed it's
rawMessage |
Constructor and Description |
---|
MessageProcessingTask(NetAccessManager netAccessManager)
Creates a Message processor.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Attempts to cancel processing of
rawMessage |
(package private) void |
resetState()
Performs proper reset of internal state of pooled instance.
|
void |
run()
Does the message parsing.
|
(package private) void |
setMessage(RawMessage message,
Consumer<MessageProcessingTask> onProcessed)
Assigns the RawMessage that will be processed
by this MessageProcessingTask on executor's thread.
|
private static final Logger logger
private final AtomicBoolean cancelled
private final NetAccessManager netAccessManager
private final ErrorHandler errorHandler
private final MessageEventHandler messageEventHandler
private RawMessage rawMessage
private Consumer<MessageProcessingTask> rawMessageProcessedHandler
rawMessage
MessageProcessingTask(NetAccessManager netAccessManager) throws IllegalArgumentException
netAccessManager
- the NetAccessManager which is creating
the new instance, is going to be its owner, specifies the
MessageEventHandler and represents the ErrorHandler to
handle exceptions in the new instanceIllegalArgumentException
- if any of the mentioned properties of
netAccessManager are nullvoid setMessage(RawMessage message, Consumer<MessageProcessingTask> onProcessed)
message
- RawMessage to be processedonProcessed
- callback which will be invoked when processing
of rawMessage
is completedvoid resetState()
public void cancel()
rawMessage
Copyright © 2018. All rights reserved.