Skip to content

Class EventTopicAttribute ​

Namespace: Momentum.Extensions.Abstractions.Messaging
Assembly: Momentum.Extensions.Abstractions.dll

Specifies the topic name for a distributed event class.

csharp
[AttributeUsage(AttributeTargets.Class)]
public class EventTopicAttribute : Attribute

Inheritance ​

object ← Attribute ← EventTopicAttribute

Derived ​

EventTopicAttribute<TEntity>

Inherited Members ​

Attribute.GetCustomAttributes(MemberInfo, Type), Attribute.GetCustomAttributes(MemberInfo, Type, bool), Attribute.GetCustomAttributes(MemberInfo), Attribute.GetCustomAttributes(MemberInfo, bool), Attribute.IsDefined(MemberInfo, Type), Attribute.IsDefined(MemberInfo, Type, bool), Attribute.GetCustomAttribute(MemberInfo, Type), Attribute.GetCustomAttribute(MemberInfo, Type, bool), Attribute.GetCustomAttributes(ParameterInfo), Attribute.GetCustomAttributes(ParameterInfo, Type), Attribute.GetCustomAttributes(ParameterInfo, Type, bool), Attribute.GetCustomAttributes(ParameterInfo, bool), Attribute.IsDefined(ParameterInfo, Type), Attribute.IsDefined(ParameterInfo, Type, bool), Attribute.GetCustomAttribute(ParameterInfo, Type), Attribute.GetCustomAttribute(ParameterInfo, Type, bool), Attribute.GetCustomAttributes(Module, Type), Attribute.GetCustomAttributes(Module), Attribute.GetCustomAttributes(Module, bool), Attribute.GetCustomAttributes(Module, Type, bool), Attribute.IsDefined(Module, Type), Attribute.IsDefined(Module, Type, bool), Attribute.GetCustomAttribute(Module, Type), Attribute.GetCustomAttribute(Module, Type, bool), Attribute.GetCustomAttributes(Assembly, Type), Attribute.GetCustomAttributes(Assembly, Type, bool), Attribute.GetCustomAttributes(Assembly), Attribute.GetCustomAttributes(Assembly, bool), Attribute.IsDefined(Assembly, Type), Attribute.IsDefined(Assembly, Type, bool), Attribute.GetCustomAttribute(Assembly, Type), Attribute.GetCustomAttribute(Assembly, Type, bool), Attribute.Equals(object?), Attribute.GetHashCode(), Attribute.Match(object?), Attribute.IsDefaultAttribute(), Attribute.TypeId, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples ​

[EventTopic("user-created", domain: "users")]
public class UserCreatedEvent : IDistributedEvent { }

Remarks ​

Apply this attribute to distributed event classes to define their topic name in the message broker. The topic name is used for routing messages to the appropriate consumers. An optional domain can be specified to override the assembly's default domain.

Constructors ​

EventTopicAttribute(string, string?, string?, string) ​

Specifies the topic name for a distributed event class.

csharp
public EventTopicAttribute(string topic, string? domain = null, string? subdomain = null, string version = "v1")

Parameters ​

topic string

domain string?

subdomain string?

version string

Examples ​

[EventTopic("user-created", domain: "users")]
public class UserCreatedEvent : IDistributedEvent { }

Remarks ​

Apply this attribute to distributed event classes to define their topic name in the message broker. The topic name is used for routing messages to the appropriate consumers. An optional domain can be specified to override the assembly's default domain.

Properties ​

CollapseTopicOnDomain ​

Whether the topic segment should be dropped from the fully-qualified topic name when it exactly matches the domain[.subdomain] path (e.g. domain "orders" with no subdomain and topic "orders" would otherwise produce "orders.orders.v1"). Defaults to true; set to false to always keep the topic segment even when it duplicates the domain path.

csharp
public bool CollapseTopicOnDomain { get; set; }

Property Value ​

bool

Domain ​

Domain for the event.

csharp
public string? Domain { get; }

Property Value ​

string?

Internal ​

Indicates if the event is internal or public (Default: public)

csharp
public bool Internal { get; set; }

Property Value ​

bool

ShouldPluralizeTopicName ​

Gets a value indicating whether the topic name should be pluralized. Returns false for explicitly named topics.

csharp
public virtual bool ShouldPluralizeTopicName { get; }

Property Value ​

bool

Subdomain ​

Subdomain for the event.

csharp
public string? Subdomain { get; }

Property Value ​

string?

Topic ​

Topic name for the event.

csharp
public string Topic { get; }

Property Value ​

string

Version ​

Event major version (Default: 'v1')

csharp
public string Version { get; }

Property Value ​

string