DataSource.NET  8.0.3.290770-7760911e
Caplin.DataSource.Messaging.ICachedMessageFactory Interface Reference

A message factory is used to create DataSource messages that can be published to other DataSources. More...

Inherited by Caplin.DataSource.Messaging.IInternalCachedMessageFactory.

Public Member Functions

IContainerMessage CreateContainerMessage (string subject)
 Create a message that defines a container. The name of the container is the given subject. More...
 
IGenericMessage CreateGenericMessage (string subject)
 Creates a Generic message to which Generic structured data can be added. More...
 
IJsonMessage CreateJsonMessage (String subject, Object json)
 
IRecordType1Message CreateRecordType1Message (string subject)
 Creates a Record message to which Type 1 structured data can be added. More...
 
ISubjectErrorEvent CreateSubjectErrorEvent (string subject, SubjectError error, params SubjectErrorFlags[] flags)
 Creates a subject error event. More...
 
ISubjectStatusEvent CreateSubjectStatusEvent (string subject, SubjectStatus status, string message)
 Creates a subject status event. More...
 

Detailed Description

A message factory is used to create DataSource messages that can be published to other DataSources.

Member Function Documentation

IContainerMessage Caplin.DataSource.Messaging.ICachedMessageFactory.CreateContainerMessage ( string  subject)

Create a message that defines a container. The name of the container is the given subject.

Parameters
subjectThe subject defining the name of the container.
Returns
A message defining the container.
IGenericMessage Caplin.DataSource.Messaging.ICachedMessageFactory.CreateGenericMessage ( string  subject)

Creates a Generic message to which Generic structured data can be added.

Parameters
subjectThe subject of the Message.
Returns
A new Generic message.

Generic messages can be used without specifying field mappings in a separate adapter configuration file. This may be useful when receiving updates from a provider which supplies a variable or unknown number of fields.

The returned message contains no data. To populate the message with data, use the appropriate methods of Caplin.DataSource.Messaging.Record.IGenericMessage.

IJsonMessage Caplin.DataSource.Messaging.ICachedMessageFactory.CreateJsonMessage ( String  subject,
Object  json 
)

Creates a JSON message for the given subject.

Parameters
subjectThe subject of the message.
jsonAn object to be serialized using the installed JsonHandler.
Returns
A new JSON message.
IRecordType1Message Caplin.DataSource.Messaging.ICachedMessageFactory.CreateRecordType1Message ( string  subject)

Creates a Record message to which Type 1 structured data can be added.

Parameters
subjectThe subject of the Record.
Returns
A new Type 1 Record message.

The returned message contains no data. To populate the message with data, use the appropriate methods of Caplin.DataSource.Messaging.Record.IRecordType1Message.

ISubjectErrorEvent Caplin.DataSource.Messaging.ICachedMessageFactory.CreateSubjectErrorEvent ( string  subject,
SubjectError  error,
params SubjectErrorFlags[]  flags 
)

Creates a subject error event.

Parameters
subjectThe subject to which the error relates.
errorThe error.
flagsAdditional Flags to be applied to the SubjectError message.
Returns
A subject error event.

The following example shows how to create an ISubjectErrorEvent for a specified subject, and send it to all peers that have requested that subject:

namespace DataSourceExamples.Messaging
{
public class SendCachedSubjectError
{
public void SendSubjectErrorEvent(ICachingPublisher publisher, string subject)
{
// Create an ISubjectErrorEvent.
ISubjectErrorEvent ev = publisher.CachedMessageFactory.CreateSubjectErrorEvent(subject, SubjectError.NotFound);
// Distribute the error to all peers that have requested this subject.
publisher.PublishSubjectErrorEvent(ev);
}
}
}
ISubjectStatusEvent Caplin.DataSource.Messaging.ICachedMessageFactory.CreateSubjectStatusEvent ( string  subject,
SubjectStatus  status,
string  message 
)

Creates a subject status event.

Parameters
subjectThe subject to which the status relates.
statusThe status.
messageA free form textual message indicating the reason for the status message being raised.
Returns
A subject status event.

The following example shows how to create an ISubjectStatusEvent for a specified subject, and send it to all peers that have requested that subject.

namespace DataSourceExamples.Messaging
{
public class SendCachedSubjectStatusEvent
{
void SendSubjectStatusToSubscribedPeers(ICachingPublisher publisher, string subject)
{
// Create a Stale subject status event.
ISubjectStatusEvent ev = publisher.CachedMessageFactory.CreateSubjectStatusEvent(subject, SubjectStatus.Stale, "Object is stale");
// And publisher to all subscribed peers.
publisher.PublishSubjectStatusEvent(ev);
}
}
}

Generated on Wed Jul 31 2024 17:13:02 for DataSource.NET