Class EventBatchContext
java.lang.Object
com.azure.messaging.eventhubs.models.EventBatchContext
A class that contains a batch of
EventData and the partition information the event batch belongs to. This is
given to the EventProcessorClientBuilder.processEventBatch(Consumer, int) and
EventProcessorClientBuilder.processEventBatch(Consumer, int, Duration) handlers each
time an event batch is received from the Event Hub. This class also includes methods to update checkpoint in
CheckpointStore and retrieve the last enqueued event information.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEventBatchContext(PartitionContext partitionContext, List<EventData> events, CheckpointStore checkpointStore, LastEnqueuedEventProperties lastEnqueuedEventProperties) Creates an instance ofEventBatchContext. -
Method Summary
Modifier and TypeMethodDescriptionReturns a list of 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 last event in the list provided bygetEvents().Updates the checkpoint asynchronously for this partition using the last event in the list provided bygetEvents().
-
Constructor Details
-
EventBatchContext
public EventBatchContext(PartitionContext partitionContext, List<EventData> events, CheckpointStore checkpointStore, LastEnqueuedEventProperties lastEnqueuedEventProperties) Creates an instance ofEventBatchContext.- Parameters:
partitionContext- The partition information associated with the received event.events- The list of events 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,events, orcheckpointStoreis null.
-
-
Method Details
-
getPartitionContext
Returns the partition information associated with the received event.- Returns:
- The partition information of the received event.
-
getEvents
Returns a list of event data received from Event Hub. An empty list can be returned ifEventProcessorClientBuilder.processEventBatch(Consumer, int, Duration)was used to construct the processor. This means that no events were received during the specified duration.- Returns:
- The list of event data received from Event Hub.
-
getLastEnqueuedEventProperties
Returns the properties of the last enqueued event in this partition. IfEventProcessorClientBuilder.trackLastEnqueuedEventProperties(boolean)is set tofalseor ifgetEvents()is empty, this method will returnnull.- Returns:
- The properties of the last enqueued event in this partition. If
EventProcessorClientBuilder.trackLastEnqueuedEventProperties(boolean)is set tofalseor ifgetEvents()is empty, this method will returnnull.
-
updateCheckpointAsync
Updates the checkpoint asynchronously for this partition using the last event in the list provided bygetEvents(). This will serve as the last known successfully processed event in this partition if the update is successful. IfgetEvents()returns an empty, no update to checkpoint will be done.- Returns:
- Gets a
Monothat completes when the checkpoint is updated.
-
updateCheckpoint
public void updateCheckpoint()Updates the checkpoint synchronously for this partition using the last event in the list provided bygetEvents(). This will serve as the last known successfully processed event in this partition if the update is successful. IfgetEvents()returns an empty, no update to checkpoint will be done.
-