Class EventContext
java.lang.Object
com.azure.messaging.eventhubs.models.EventContext
A class that contains
EventData and the partition information the event belongs to. This is given to the
processEvent and
EventProcessorClientBuilder.processEvent(Consumer, Duration) 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
ConstructorsConstructorDescriptionEventContext(PartitionContext partitionContext, EventData eventData, CheckpointStore checkpointStore, LastEnqueuedEventProperties lastEnqueuedEventProperties) Creates an instance ofEventContext. -
Method Summary
Modifier and TypeMethodDescriptionReturns the event data received from Event Hub.Returns the properties of the last enqueued event in this partition.Returns the partition information associated with the received event.voidUpdates the checkpoint synchronously for this partition using the event data.Updates the checkpoint asynchronously for this partition using the event data in thisEventContext.
-
Constructor Details
-
EventContext
public EventContext(PartitionContext partitionContext, EventData eventData, CheckpointStore checkpointStore, LastEnqueuedEventProperties lastEnqueuedEventProperties) Creates an instance ofEventContext.- Parameters:
partitionContext- The partition information associated with the received event.eventData- The event received from Event Hub.checkpointStore- The checkpoint store that is used for updating checkpoints.lastEnqueuedEventProperties- The properties of the last enqueued event in this partition. IfEventProcessorClientBuilder.trackLastEnqueuedEventProperties(boolean)is set tofalse, this will benull.- Throws:
NullPointerException- IfpartitionContext,eventDataorcheckpointStoreis null.
-
-
Method Details
-
getPartitionContext
Returns the partition information associated with the received event.- Returns:
- The partition information of the received event.
-
getEventData
Returns the event data received from Event Hub. Can benullifEventProcessorClientBuilder.processEvent(Consumer, Duration)was used to construct the processor. This means that no event was received during the specified duration.- Returns:
- The event data received from Event Hub or
null.
-
getLastEnqueuedEventProperties
Returns the properties of the last enqueued event in this partition. IfEventProcessorClientBuilder.trackLastEnqueuedEventProperties(boolean)is set tofalse, this method will returnnull.- Returns:
- The properties of the last enqueued event in this partition. If
EventProcessorClientBuilder.trackLastEnqueuedEventProperties(boolean)is set tofalse, this method will returnnull.
-
updateCheckpointAsync
Updates the checkpoint asynchronously for this partition using the event data in thisEventContext. This will serve as the last known successfully processed event in this partition if the update is successful.- Returns:
- A representation of deferred execution of this call.
-
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.
-