EventContext Class
- java.
lang. Object - com.
azure. messaging. eventhubs. models. EventContext
- com.
public class EventContext
A class that contains EventData and the partition information the event belongs to. This is given to the processEvent(Consumer<EventContext> processEvent) and processEvent(Consumer<EventContext> processEvent, Duration maxWaitTime) handlers each time an event is received from the Event Hub or when the maxWaitTime duration has elapsed. This class also includes methods to update checkpoint in CheckpointStore and retrieve the last enqueued event information.
Constructor Summary
| Constructor | Description |
|---|---|
| EventContext(PartitionContext partitionContext, EventData eventData, CheckpointStore checkpointStore, LastEnqueuedEventProperties lastEnqueuedEventProperties) |
Creates an instance of EventContext. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
Event |
getEventData()
Returns the event data received from Event Hub. |
|
Last |
getLastEnqueuedEventProperties()
Returns the properties of the last enqueued event in this partition. |
|
Partition |
getPartitionContext()
Returns the partition information associated with the received event. |
| void |
updateCheckpoint()
Updates the checkpoint synchronously for this partition using the event data. |
| reactor.core.publisher.Mono<Void> |
updateCheckpointAsync()
Updates the checkpoint asynchronously for this partition using the event data in this EventContext. |
Methods inherited from java.lang.Object
Constructor Details
EventContext
public EventContext(PartitionContext partitionContext, EventData eventData, CheckpointStore checkpointStore, LastEnqueuedEventProperties lastEnqueuedEventProperties)
Creates an instance of EventContext.
Parameters:
false, this will be
null.
Method Details
getEventData
public EventData getEventData()
Returns the event data received from Event Hub. Can be null if processEvent(Consumer<EventContext> processEvent, Duration maxWaitTime) was used to construct the processor. This means that no event was received during the specified duration.
Returns:
null.getLastEnqueuedEventProperties
public LastEnqueuedEventProperties getLastEnqueuedEventProperties()
Returns the properties of the last enqueued event in this partition. If trackLastEnqueuedEventProperties(boolean trackLastEnqueuedEventProperties) is set to false, this method will return null.
Returns:
false, this method will return null.getPartitionContext
public PartitionContext getPartitionContext()
Returns the partition information associated with the received event.
Returns:
updateCheckpoint
public void updateCheckpoint()
Updates the checkpoint synchronously for this partition using the event data. This will serve as the last known successfully processed event in this partition if the update is successful.
updateCheckpointAsync
public Mono<Void> updateCheckpointAsync()
Updates the checkpoint asynchronously for this partition using the event data in this EventContext. This will serve as the last known successfully processed event in this partition if the update is successful.
Returns: