Skip to main content

Definition

Assembly: CloudNimble.SimpleMessageBus.Core.dll Namespace: CloudNimble.SimpleMessageBus.Core Inheritance: System.Object

Syntax

CloudNimble.SimpleMessageBus.Core.MessageBase

Summary

Base class providing a complete implementation of common message functionality.

Remarks

MessageBase provides a convenient base class that implements all core message interfaces, making it easy to create new message types without having to implement the common functionality manually. It automatically handles ID generation, metadata initialization, tracking properties, and provides constructors for creating child messages with proper lineage tracking. This class is abstract and must be inherited to create concrete message types. It’s recommended to use this base class for most message implementations unless you have specific requirements that prevent inheritance.

Examples

// Simple message inheriting from MessageBase
public class OrderCreatedMessage : MessageBase
{
    public string OrderNumber { get; set; }
    public decimal TotalAmount { get; set; }
    public DateTime CreatedAt { get; set; }
}

// Creating a root message
var orderMessage = new OrderCreatedMessage
{
    OrderNumber = "ORD-001",
    TotalAmount = 99.99m,
    CreatedAt = DateTime.UtcNow
};

// Creating a child message with proper lineage
public class PaymentProcessedMessage : MessageBase
{
    public decimal Amount { get; set; }
    public string PaymentMethod { get; set; }

    public PaymentProcessedMessage(IMessage parent) : base(parent)
    {
        // Child-specific initialization
    }
}

var paymentMessage = new PaymentProcessedMessage(orderMessage)
{
    Amount = 99.99m,
    PaymentMethod = "CreditCard"
};
// paymentMessage.ParentId == orderMessage.Id
// paymentMessage.CorrelationId == orderMessage.CorrelationId

Constructors

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

CorrelationId

Syntax

public System.Guid CorrelationId { get; set; }

Property Value

Type: System.Guid

Id

Syntax

public System.Guid Id { get; set; }

Property Value

Type: System.Guid

Metadata

Syntax

public System.Collections.Concurrent.ConcurrentDictionary<string, object> Metadata { get; set; }

Property Value

Type: System.Collections.Concurrent.ConcurrentDictionary<string, object>

ParentId

Syntax

public System.Nullable<System.Guid> ParentId { get; set; }

Property Value

Type: System.Nullable<System.Guid>

Methods

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?
  • CloudNimble.SimpleMessageBus.Core.IMessage
  • CloudNimble.SimpleMessageBus.Core.IMetadataAware
  • CloudNimble.SimpleMessageBus.Core.ITrackable