public class MessageProcessingContext<T extends Message<?>> extends Object
UnitOfWork.Phase
.Constructor and Description |
---|
MessageProcessingContext(T message)
Creates a new processing context for the given
message . |
Modifier and Type | Method and Description |
---|---|
void |
addHandler(UnitOfWork.Phase phase,
Consumer<UnitOfWork<T>> handler)
Adds a handler to the collection.
|
ExecutionResult |
getExecutionResult()
Get the result of processing the
Message . |
T |
getMessage()
Get the Message that is being processed in this context.
|
void |
notifyHandlers(UnitOfWork<T> unitOfWork,
UnitOfWork.Phase phase)
Invoke the handlers in this collection attached to the given
phase . |
void |
reset(T message)
Reset the processing context.
|
void |
setExecutionResult(ExecutionResult executionResult)
Set the execution result of processing the current
Message . |
void |
transformMessage(Function<T,? extends Message<?>> transformOperator)
Transform the Message being processed using the given operator.
|
public MessageProcessingContext(T message)
message
.message
- The Message that is to be processed.public void notifyHandlers(UnitOfWork<T> unitOfWork, UnitOfWork.Phase phase)
phase
.unitOfWork
- The Unit of Work that is changing its phasephase
- The phase for which attached handlers should be invokedpublic void addHandler(UnitOfWork.Phase phase, Consumer<UnitOfWork<T>> handler)
phase
- The phase of the unit of work to attach the handler tohandler
- The handler to invoke in the given phasepublic void setExecutionResult(ExecutionResult executionResult)
Message
. In case this context has a
previously set ExecutionResult, setting a new result is only allowed if the new result is an exception result.
In case the previously set result is also an exception result, the exception in the new execution result is
added to the original exception as a suppressed exception.executionResult
- the ExecutionResult of the currently handled Messagepublic T getMessage()
public ExecutionResult getExecutionResult()
Message
. If the Message has not been processed yet this
method returns null
.null
if the Message hasn't been processedpublic void transformMessage(Function<T,? extends Message<?>> transformOperator)
transformOperator
- The transform operator to apply to the stored messagepublic void reset(T message)
message
.message
- The new message that is being processedCopyright © 2010–2020. All rights reserved.