Class MessageProcessor<TSossObject>
- Namespace
- Scaleout.Modules.Abstractions
- Assembly
- Scaleout.Modules.Abstractions.dll
Provides an abstract base class for processing messages sent to an object in the ScaleOut service.
public abstract class MessageProcessor<TSossObject>
Type Parameters
TSossObjectType of object stored in the ScaleOut StateServer (SOSS) service.
- Inheritance
-
MessageProcessor<TSossObject>
- Inherited Members
Remarks
Implementations of this class should define the logic for processing messages in the ProcessMessage method.
Methods
CreateObject(string, string)
Factory callback for creating a new TSossObject object instance.
Called by the runtime when a message is sent to an object that does not exist in the ScaleOut service.
GetNewObjectPolicy(string, string, TSossObject), will be called immediately after this method returns,
followed by the ProcessMessageAsync(MessageProcessingContext<TSossObject>, TSossObject, byte[]) implementation.
public abstract TSossObject CreateObject(string moduleName, string objectId)
Parameters
moduleNamestringName of your message processing module, as supplied to ModulePackage.AddMsgModule().
objectIdstringUnique ID of the object in the ScaleOut service.
Returns
- TSossObject
New
TSossObjectobject instance.
GetNewObjectPolicy(string, string, TSossObject)
Factory callback for creating a policy that specifies the expiration behavior for a newly created object.
public abstract NewObjectPolicy GetNewObjectPolicy(string moduleName, string objectId, TSossObject newObject)
Parameters
moduleNamestringName of your message processing module, as supplied to ModulePackage.AddMsgModule().
objectIdstringUnique ID of the object in the ScaleOut service.
newObjectTSossObjectThe newly created object instance, as returned from your CreateObject implementation or a read-through operation.
Returns
- NewObjectPolicy
A policy that specifies the expiration behavior for the newly created object.
ProcessMessageAsync(MessageProcessingContext<TSossObject>, TSossObject, byte[])
Processes an incoming message for an object in the module.
public abstract Task<ProcessingResult> ProcessMessageAsync(MessageProcessingContext<TSossObject> context, TSossObject sossObject, byte[] msgBytes)
Parameters
contextMessageProcessingContext<TSossObject>The processing context that provides metadata and operational details for handling the message.
sossObjectTSossObjectThe object in the ScaleOut service that is associated with the message being processed.
msgBytesbyte[]Message data to be processed.
Returns
- Task<ProcessingResult>
A ProcessingResult indicating whether modifications to the object should be persisted or whether the object should be removed.