We will be sunsetting Advisor during Jan, 2026 and will instead be providing information in Snyk Security DB.

You can begin to take advantage of Snyk Security DB today for a unified, package-centric experience.

How to use @azure/eventhubs-checkpointstore-blob - 2 common examples

To help you get started, we’ve selected a few @azure/eventhubs-checkpointstore-blob 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)
  });
}
github Azure / azure-sdk-for-js / sdk / eventhub / event-hubs / samples / receiveEventsUsingCheckpointStore.ts View on Github external
export async function main() {
  console.log(`Running receiveEventsUsingCheckpointStore sample`);

  // this client will be used by our eventhubs-checkpointstore-blob, which 
  // persists any checkpoints from this session in Azure Storage
  const containerClient = new ContainerClient(storageConnectionString, containerName);

  if (!(await containerClient.exists())) {
    await containerClient.create();
  }

  const checkpointStore : CheckpointStore = new BlobCheckpointStore(containerClient);

  const consumerClient = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName, checkpointStore);
   
  const subscription = consumerClient.subscribe({
      processEvents: async (events, context) => {
        for (const event of events) {
          console.log(`Received event: '${event.body}' from partition: '${context.partitionId}' and consumer group: '${context.consumerGroup}'`);
        }
    
        try {
          // save a checkpoint for the last event now that we've processed this batch.
          await context.updateCheckpoint(events[events.length - 1]);
        } catch (err) {
          console.log(`Error when checkpointing on partition ${context.partitionId}: `, err);
          throw err;
        };

@azure/eventhubs-checkpointstore-blob

An Azure Storage Blob solution to store checkpoints when using Event Hubs.

MIT
Latest version published 9 months ago

Package Health Score

78 / 100
Full package analysis