EventPosition Class

  • java.lang.Object
    • com.azure.messaging.eventhubs.models.EventPosition

public final class EventPosition

Defines a position of an EventData in the Event Hub partition stream. The position can be an offset, sequence number, or enqueued time in UTC.

Method Summary

Modifier and Type Method and Description
static EventPosition earliest()

Corresponds to the location of the first event present in the partition.

boolean equals(Object obj)
static EventPosition fromEnqueuedTime(Instant enqueuedDateTime)

Creates a position at the given Instant.

static EventPosition fromOffset(long offset)

Creates a position to an event in the partition at the provided offset.

static EventPosition fromSequenceNumber(long sequenceNumber)

Creates a position to an event in the partition at the provided sequence number.

static EventPosition fromSequenceNumber(long sequenceNumber, boolean isInclusive)

Creates a position at the given sequence number.

Instant getEnqueuedDateTime()

Gets the instant, in UTC, from which the next available event should be chosen.

String getOffset()

Gets the relative position for event in the context of the stream.

Long getSequenceNumber()

Gets the sequence number of the event.

int hashCode()
boolean isInclusive()

Gets the boolean value of if the event is included.

static EventPosition latest()

Corresponds to the end of the partition, where no more events are currently enqueued.

String toString()

Methods inherited from java.lang.Object

Method Details

earliest

public static EventPosition earliest()

Corresponds to the location of the first event present in the partition. Use this position to begin receiving from the first event that was enqueued in the partition which has not expired due to the retention policy.

Returns:

An EventPosition set to the start of an Event Hub stream.

equals

public boolean equals(Object obj)

Overrides:

EventPosition.equals(Object obj)

Parameters:

obj

fromEnqueuedTime

public static EventPosition fromEnqueuedTime(Instant enqueuedDateTime)

Creates a position at the given Instant. Corresponds to a specific instance within a partition to begin looking for an event. The event enqueued after the requested enqueuedDateTime becomes the current position.

Parameters:

enqueuedDateTime - The instant, in UTC, from which the next available event should be chosen.

Returns:

An EventPosition object.

fromOffset

public static EventPosition fromOffset(long offset)

Creates a position to an event in the partition at the provided offset. The event at that offset will not be included. Instead, the next event is returned.

The offset is the relative position for event in the context of the stream. The offset should not be considered a stable value, as the same offset may refer to a different event as events reach the age limit for retention and are no longer visible within the stream.

Parameters:

offset - The offset of the event within that partition.

Returns:

An EventPosition object.

fromSequenceNumber

public static EventPosition fromSequenceNumber(long sequenceNumber)

Creates a position to an event in the partition at the provided sequence number. The event with the sequence number will not be included. Instead, the next event is returned.

Parameters:

sequenceNumber - is the sequence number of the event.

Returns:

An EventPosition object.

fromSequenceNumber

public static EventPosition fromSequenceNumber(long sequenceNumber, boolean isInclusive)

Creates a position at the given sequence number. If isInclusive is true, the event with the same sequence number is returned. Otherwise, the next event in the sequence is received.

Parameters:

sequenceNumber - is the sequence number of the event.
isInclusive - If true, the event with the sequenceNumber is included; otherwise, the next event will be received.

Returns:

An EventPosition object.

getEnqueuedDateTime

public Instant getEnqueuedDateTime()

Gets the instant, in UTC, from which the next available event should be chosen.

Returns:

The instant, in UTC, from which the next available event should be chosen.

getOffset

public String getOffset()

Gets the relative position for event in the context of the stream. The offset should not be considered a stable value, as the same offset may refer to a different event as events reach the age limit for retention and are no longer visible within the stream.

Returns:

The offset of the event within that partition.

getSequenceNumber

public Long getSequenceNumber()

Gets the sequence number of the event.

Returns:

The sequence number of the event.

hashCode

public int hashCode()

Overrides:

EventPosition.hashCode()

isInclusive

public boolean isInclusive()

Gets the boolean value of if the event is included. If true, the event with the sequenceNumber is included; otherwise, the next event will be received.

Returns:

The boolean if the event will be received.

latest

public static EventPosition latest()

Corresponds to the end of the partition, where no more events are currently enqueued. Use this position to begin receiving from the next event to be enqueued in the partition when receiveFromPartition(String partitionId, EventPosition startingPosition) invoked.

Returns:

An EventPosition set to the end of an Event Hubs stream and listens for new events.

toString

public String toString()

Overrides:

EventPosition.toString()

Applies to