Class KafkaMessageContext
Kafka-specific message context providing access to Kafka partitioning and offset properties.
public sealed class KafkaMessageContext : TransportMessageContext, ITransportMessageContext
- Inheritance
-
KafkaMessageContext
- Implements
- Inherited Members
- Extension Methods
Remarks
This context extends TransportMessageContext with Kafka-specific properties such as topic, partition, offset, and key. These properties are stored as transport properties and can be accessed through strongly-typed properties or via GetTransportProperty<T>(string).
Constructors
KafkaMessageContext()
Initializes a new instance of the KafkaMessageContext class with a generated message ID.
public KafkaMessageContext()
KafkaMessageContext(string)
Initializes a new instance of the KafkaMessageContext class.
public KafkaMessageContext(string messageId)
Parameters
messageIdstringThe unique message identifier.
Fields
KeyPropertyName
The transport property name for the message key.
public const string KeyPropertyName = "Key"
Field Value
LeaderEpochPropertyName
The transport property name for the leader epoch.
public const string LeaderEpochPropertyName = "LeaderEpoch"
Field Value
OffsetPropertyName
The transport property name for the offset.
public const string OffsetPropertyName = "Offset"
Field Value
PartitionPropertyName
The transport property name for the partition.
public const string PartitionPropertyName = "Partition"
Field Value
SchemaIdPropertyName
The transport property name for the schema ID (for Avro/Protobuf schemas).
public const string SchemaIdPropertyName = "SchemaId"
Field Value
TopicPropertyName
The transport property name for the topic.
public const string TopicPropertyName = "Topic"
Field Value
Properties
Key
Gets or sets the message key.
public string? Key { get; set; }
Property Value
- string
The message key used for partitioning. Messages with the same key are guaranteed to be sent to the same partition.
LeaderEpoch
Gets or sets the leader epoch at the time the message was produced.
public int? LeaderEpoch { get; set; }
Property Value
Offset
Gets or sets the offset within the partition.
public long Offset { get; set; }
Property Value
- long
The offset of the message within its partition.
Partition
Gets or sets the partition number.
public int Partition { get; set; }
Property Value
- int
The partition number, or -1 if not assigned.
SchemaId
Gets or sets the schema ID for schema registry integration.
public int? SchemaId { get; set; }
Property Value
Topic
Gets or sets the Kafka topic name.
public string? Topic { get; set; }
Property Value
- string
The topic this message was published to or consumed from.