Class CorrelationToken
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
CorrelationToken(string)
Initializes a new instance of the CorrelationToken class.
public CorrelationToken(string correlationId = null)
Parameters
correlationIdstringThe string that uniquely identifies a correlation. Default value is a GUID expressed as 32 digits.
Properties
CorrelationId
Gets the unique correlation identifier.
public string CorrelationId { get; }
Property Value
- string
The unique correlation identifier.
Methods
ToString()
Returns a string that represents this instance.
public override string ToString()