Table of Contents

CorrelationToken Class

Definition

Namespace
Cuemon.Messaging
Assemblies
Cuemon.Core.dll
Source
src/Cuemon.Core/Messaging/CorrelationToken.cs

Provides a default implementation of the ICorrelationToken interface.

public record CorrelationToken : ICorrelationToken, IEquatable<CorrelationToken>
Inheritance
CorrelationToken
Implements

Examples

The following example shows how to create one correlation identifier and pass it through related work.

using System;
using Cuemon.Messaging;

namespace MyApp.Examples;

public static class CorrelationTokenExample
{
    public static void Demonstrate()
    {
        var generated = new CorrelationToken();
        var provided = new CorrelationToken("order-2026-0001");

        Console.WriteLine(generated.CorrelationId.Length == 32);
        Console.WriteLine(provided.ToString());
        Console.WriteLine(AttachToMessage("InventoryReserved", provided));
    }

    private static string AttachToMessage(string messageType, ICorrelationToken token)
    {
        return $"{messageType}:{token.CorrelationId}";
    }
}

Constructors

Name Description
CorrelationToken(string)

Initializes a new instance of the CorrelationToken class.

Properties

Name Description
CorrelationId

Gets the unique correlation identifier.

Methods

Name Description
ToString()

Returns a string that represents this instance.

See Also