Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private static async SendAndReceiveEvents() {
console.log("creating consumer...");
const consumer = EventHubs.client.createConsumer(
EventHubClient.defaultConsumerGroupName,
EventHubs.partitionId[0],
EventPosition.fromEnqueuedTime(new Date())
);
console.log("sending events...");
const producerOptions = {
partitionId: EventHubs.partitionId[0]
};
const producer = EventHubs.client.createProducer(producerOptions);
await producer.send({ body: "JS Event Test 1" });
await producer.send({ body: "JS Event Test 2" });
await producer.send({ body: "JS Event Test 3" });
console.log("receiving events...");
let eventsReceived = await consumer.receiveBatch(3, 5);
eventsReceived.forEach((event) => {