Class PartitionContext
- java.lang.Object
-
- com.microsoft.azure.eventprocessorhost.PartitionContext
-
public class PartitionContext extends Object
PartitionContext is used to provide partition-related information to the methods of IEventProcessor, particularly onEvents where the user's event-processing logic lives. It also allows the user to persist checkpoints for the partition, which determine where event processing will begin if the event processor for that partition must be restarted, such as if ownership of the partition moves from one event processor host instance to another.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Void>
checkpoint()
Writes the position of the last event in the current batch to the checkpoint store via the checkpoint manager.CompletableFuture<Void>
checkpoint(EventData event)
Writes the position of the provided EventData instance to the checkpoint store via the checkpoint manager.CompletableFuture<Void>
checkpoint(Checkpoint checkpoint)
Writes the position of the provided Checkpoint instance to the checkpoint store via the checkpoint manager.String
getConsumerGroupName()
Get the name of the consumer group that is being received from.String
getEventHubPath()
Get the path of the event hub that is being received from.String
getOwner()
Get the name of the event processor host instance.String
getPartitionId()
Get the id of the partition being received from.ReceiverRuntimeInformation
getRuntimeInformation()
If receiver runtime metrics have been enabled in EventProcessorHost, this method gets the metrics as they come in.
-
-
-
Method Detail
-
getConsumerGroupName
public String getConsumerGroupName()
Get the name of the consumer group that is being received from.- Returns:
- consumer group name
-
getEventHubPath
public String getEventHubPath()
Get the path of the event hub that is being received from.- Returns:
- event hub path
-
getOwner
public String getOwner()
Get the name of the event processor host instance.- Returns:
- event processor host instance name
-
getRuntimeInformation
public ReceiverRuntimeInformation getRuntimeInformation()
If receiver runtime metrics have been enabled in EventProcessorHost, this method gets the metrics as they come in.- Returns:
- See ReceiverRuntimeInformation.
-
getPartitionId
public String getPartitionId()
Get the id of the partition being received from.- Returns:
- partition id
-
checkpoint
public CompletableFuture<Void> checkpoint()
Writes the position of the last event in the current batch to the checkpoint store via the checkpoint manager.It is important to check the result in order to detect failures.
If receiving started from a user-provided EventPosition and no events have been received yet, then this will fail. (This scenario is possible when invoke-after-receive-timeout has been set in EventProcessorOptions.)
- Returns:
- CompletableFuture -> null when the checkpoint has been persisted successfully, completes exceptionally on error.
-
checkpoint
public CompletableFuture<Void> checkpoint(EventData event)
Writes the position of the provided EventData instance to the checkpoint store via the checkpoint manager.It is important to check the result in order to detect failures.
- Parameters:
event
- A received EventData- Returns:
- CompletableFuture -> null when the checkpoint has been persisted successfully, completes exceptionally on error.
-
checkpoint
public CompletableFuture<Void> checkpoint(Checkpoint checkpoint)
Writes the position of the provided Checkpoint instance to the checkpoint store via the checkpoint manager. It is important to check the result in order to detect failures.- Parameters:
checkpoint
- a checkpoint- Returns:
- CompletableFuture -> null when the checkpoint has been persisted successfully, completes exceptionally on error.
-
-