use of com.azure.messaging.eventhubs.EventProcessorClientBuilder in project springboot-samples by joergjo.
the class EventHubWorker method run.
public void run() {
logger.info("Worker is starting");
var blobContainerAsyncClient = new BlobContainerClientBuilder().connectionString(storageConnectionString).containerName(containerName).buildAsyncClient();
Consumer<EventContext> processEvent = eventContext -> {
logger.info("Processing event: Event Hub name = {}; consumer group name = {}; partition id = {}; sequence number = {}", eventContext.getPartitionContext().getEventHubName(), eventContext.getPartitionContext().getConsumerGroup(), eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber());
eventContext.updateCheckpoint();
total.increment();
};
Consumer<ErrorContext> processError = errorContext -> {
logger.error("Error while processing {}, {}, {}, {}", errorContext.getPartitionContext().getEventHubName(), errorContext.getPartitionContext().getConsumerGroup(), errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable().getMessage());
};
eventProcessorClient = new EventProcessorClientBuilder().consumerGroup(consumerGroup).connectionString(eventHubConnectionString, eventHubName).processEvent(processEvent).processError(processError).checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)).buildEventProcessorClient();
eventProcessorClient.start();
logger.info("Worker has started");
}
Aggregations