Table of Contents

Message<T> Class

Definition

Namespace
Savvyio.Messaging
Assemblies
Savvyio.Messaging.dll
Source
src/Savvyio.Messaging/Message.cs

Provides a default implementation of the IMessage<T> interface.

public record Message<T> : Acknowledgeable, IEquatable<Acknowledgeable>, IMessage<T>, IAcknowledgeable, IEquatable<Message<T>> where T : IRequest

Type Parameters

T

The type of the payload constraint to the IRequest interface.

Inheritance
Message<T>
Implements
Inherited Members
Extension Methods

Examples

Wrap a request in a Message<T> envelope to prepare it for transport to another subsystem. The envelope pairs the payload with a source URI, a type discriminator, and a unique ID.

using System;
using Savvyio;
using Savvyio.Messaging;

namespace ExampleApp;

public sealed class MessageExample
{
    public void Send()
    {
        var message = new Message<CreateOrderCommand>(
            "msg-42",
            new Uri("urn:orders"),
            "orders.create",
            new CreateOrderCommand("ORD-42"));

        Console.WriteLine($"Sending message {message.Id} from {message.Source} with type {message.Type}");
    }
}

public sealed record CreateOrderCommand(string OrderId) : Request;

Constructors

Name Description
Message(string, Uri, string, T, DateTime?)

Initializes a new instance of the Message<T> class.

Properties

Name Description
Data

Gets the payload of the message.

Id

Gets the identifier of the message. When combined with Source, this enables deduplication.

Source

Gets the context that describes the origin of the message. When combined with Id, this enables deduplication.

Time

Gets the time, expressed as the Coordinated Universal Time (UTC), at which this message was generated.

Type

Gets the type that describes the type of event related to the originating occurrence.

See Also