Table of Contents

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

TSossObject

Type 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. ProcessMessageAsync(MessageProcessingContext<TSossObject>, TSossObject, byte[]) will be called immediately after this method returns, and the newly created object will be passed as the sossObject parameter.

public abstract CreateResult<TSossObject> CreateObject(string moduleName, string objectId)

Parameters

moduleName string

Name of your message processing module, as supplied to ModulePackage.AddMsgModule().

objectId string

Unique ID of the object in the ScaleOut service.

Returns

CreateResult<TSossObject>

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

context MessageProcessingContext<TSossObject>

The processing context that provides metadata and operational details for handling the message.

sossObject TSossObject

The object in the ScaleOut service that is associated with the message being processed.

msgBytes byte[]

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.

Remarks

NoUpdate value can be returned to indicate that the sossObject instance was not modified and does not need to be updated in the ScaleOut service. NoUpdate should not be returned if the object was modified in any way. If you are unsure of whether the sossObject was modified, return DoUpdate.