Table of Contents

Class EventData

Namespace
Microsoft.ServiceBus.Messaging
Assembly
Microsoft.ServiceBus.dll

Represents the event sent and received from an Event Hubs stream. It contains the body of the event, a user-defined property bag, and various metadata describing the event, such as its offset in the partition and its number in the stream sequence. Partitions are filled with a sequence of event data.

public sealed class EventData : IDisposable
Inheritance
EventData
Implements
Inherited Members

Constructors

EventData()

Initializes a new instance of the EventData class.

public EventData()

EventData(byte[])

Initializes a new instance of the EventData class that uses the specified byte array as the body.

public EventData(byte[] byteArray)

Parameters

byteArray byte[]

The event data byte array which is used to form the body stream.

Remarks

You should treat the input byte array as immutable when sending EventData.

        When sending the data as well as any cloning operation, 
        Service Bus will access the byte array by reference 
        rather that by deep copy of the byte array. Also disposing
        the EventData instance will only de-reference the association
        with the array. The user is responsible for the lifecycle of the
        byte-array itself.

EventData(IList<ArraySegment<byte>>)

Initializes a new instance of the EventData class that uses the specified list of byte array segments as the body.

public EventData(IList<ArraySegment<byte>> arraySegments)

Parameters

arraySegments IList<ArraySegment<byte>>

An IList of array segments to be sent as the body of the EventData.

Remarks

Typically user will use IList<ArraySegment<byte>> when using there own buffer pool for scenarios that require efficient usage of memory.

        When sending the data as well as any cloning operation, 
        Service Bus will access the array segments by reference 
        rather that by deep copy of the bytes. 

        Disposing the EventData instance will only de-reference the association
        with the list. User is responsible for the life cycle of the
        array segments themselves.

EventData(Stream)

Initializes a new instance of the EventData class that uses the argument stream as the body stream.

public EventData(Stream stream)

Parameters

stream Stream

A stream which is used as the body stream.

Remarks

User is expected to own the disposing of the stream when using this constructor.

EventData(object, XmlObjectSerializer)

Constructor which takes the input content and serializer to create the body stream.

public EventData(object content, XmlObjectSerializer serializer)

Parameters

content object

.Net object

serializer XmlObjectSerializer

the serializer used to serialize content

Remarks

If content is a stream and seriazlier is null, then it is equate to use EventData(Stream)

Properties

EnqueuedTimeUtc

Gets or sets the date and time of the sent time in UTC.

public DateTime EnqueuedTimeUtc { get; }

Property Value

DateTime

The enqueue time in UTC. This value represents the actual time of enqueuing the event data.

Offset

Gets the offset of the data relative to the Event Hub partition stream. The offset is a marker or identifier for an event within the Event Hubs stream. The identifier is unique within a partition of the Event Hubs stream.

public string Offset { get; }

Property Value

string

The read offset of the event data.

PartitionKey

Gets or sets the key that is used to determine to which partition to send event data.

public string PartitionKey { get; set; }

Property Value

string

A partition key for the partition to which event data should be sent.

Properties

Gets the user properties of the event data that the user explicitly added during send operations.

public IDictionary<string, object> Properties { get; }

Property Value

IDictionary<string, object>

The user properties of the event data.

SequenceNumber

Gets the logical sequence number of the event within the partition stream of the Event Hub.

public long SequenceNumber { get; }

Property Value

long

The logical sequence number of the event.

SerializedSizeInBytes

public long SerializedSizeInBytes { get; }

Property Value

long

SystemProperties

Gets or sets the system properties, including the event data.

public IDictionary<string, object> SystemProperties { get; }

Property Value

IDictionary<string, object>

The system properties, including the event data.

Methods

Clone()

Makes a deep copy of this event data.

public EventData Clone()

Returns

EventData

A copy of this event data.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetBodyStream()

Gets or sets the underlying stream to the event data body.

public Stream GetBodyStream()

Returns

Stream

The underlying stream to the event data body.

Remarks

This method can only be called once and afterwards method will throw InvalidOperationException.

GetBytes()

Gets the event data bytes.

public byte[] GetBytes()

Returns

byte[]

The event data bytes.