EventPosition Class
- java.
lang. Object - com.
azure. messaging. eventhubs. models. EventPosition
- com.
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
Event |
earliest()
Corresponds to the location of the first event present in the partition. |
boolean | equals(Object obj) |
static
Event |
fromEnqueuedTime(Instant enqueuedDateTime)
Creates a position at the given Instant. |
static
Event |
fromOffset(long offset)
Creates a position to an event in the partition at the provided offset. |
static
Event |
fromSequenceNumber(long sequenceNumber)
Creates a position to an event in the partition at the provided sequence number. |
static
Event |
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
Event |
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:
equals
public boolean equals(Object obj)
Overrides:
EventPosition.equals(Object obj)Parameters:
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:
Returns:
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:
Returns:
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:
Returns:
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 included; otherwise, the next event
will be received.
Returns:
getEnqueuedDateTime
public Instant getEnqueuedDateTime()
Gets the instant, in UTC, from which the next available event should be chosen.
Returns:
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:
getSequenceNumber
public Long getSequenceNumber()
Gets the sequence number of the event.
Returns:
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:
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:
toString
public String toString()
Overrides:
EventPosition.toString()Applies to
Azure SDK for Java