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. 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

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

TSossObject

New TSossObject object 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

moduleName string

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

objectId string

Unique ID of the object in the ScaleOut service.

newObject TSossObject

The 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

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.