How to use the @azure/event-hubs.EventHubConsumerClient.defaultConsumerGroupName function in @azure/event-hubs

To help you get started, we’ve selected a few @azure/event-hubs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / eventhub / eventhubs-checkpointstore-eventProcessor.ts View on Github external
console.log(
        `Received event: '${event.body}' from partition: '${context.partitionId}' and consumer group: '${context.consumerGroupName}'`
      );
    }

    // checkpoint using the last event in the batch
    const lastEvent = events[events.length - 1];
    await context.updateCheckpoint(lastEvent).catch((err) => {
      console.log(`Error when checkpointing on partition ${context.partitionId}: `, err);
    });
    console.log(
      `Successfully checkpointed event with sequence number: ${lastEvent.sequenceNumber} from partition: 'partitionContext.partitionId'`
    );
  }

  const subscription = consumerClient.subscribe(EventHubConsumerClient.defaultConsumerGroupName, processEvents, new BlobPartitionManager(containerClient))

  // after 30 seconds, stop processing
  await new Promise(resolve => {
    setInterval(async () => {
      await subscription.close();
      await consumerClient.close();
      resolve();
    }, 30000)
  });
}