Class EventPosition
java.lang.Object
com.azure.messaging.eventhubs.models.EventPosition
Defines a position of an
EventData
in the Event Hub partition. The position can be an offset, sequence
number, or enqueued time.-
Method Summary
Modifier and TypeMethodDescriptionstatic EventPosition
earliest()
Corresponds to the location of the first event present in the partition.boolean
static EventPosition
fromEnqueuedTime
(Instant enqueuedDateTime) Creates a position at the givenInstant
.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.Gets the instant, in UTC, from which the next available event should be chosen.Gets the relative position for event in the context of the stream.Gets the sequence number of the event.int
hashCode()
boolean
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.toString()
-
Method Details
-
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.
-
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 whenreceiveFromPartition()
invoked.- Returns:
- An
EventPosition
set to the end of an Event Hubs stream and listens for new events.
-
fromEnqueuedTime
Creates a position at the givenInstant
. Corresponds to a specific instance within a partition to begin looking for an event. The event enqueued after the requestedenqueuedDateTime
becomes the current position.- Parameters:
enqueuedDateTime
- The instant, in UTC, from which the next available event should be chosen.- Returns:
- An
EventPosition
object.
-
fromOffset
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
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
Creates a position at the given sequence number. IfisInclusive
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 thesequenceNumber
is included; otherwise, the next event will be received.- Returns:
- An
EventPosition
object.
-
isInclusive
public boolean isInclusive()Gets the boolean value of if the event is included. If true, the event with thesequenceNumber
is included; otherwise, the next event will be received.- Returns:
- The boolean if the event will be received.
-
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
Gets the sequence number of the event.- Returns:
- The sequence number of the event.
-
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.
-
toString
-
equals
-
hashCode
public int hashCode()
-