【发布时间】:2021-08-17 07:40:21
【问题描述】:
下面是 server.js 代码。下面的代码是否将数据推送到 Azure 事件中心?如何交叉检查推送的数据? 数据包含 data ={name:'name',dob:'01-12-2000}
const { EventHubProducerClient } =
require("@azure/event-hubs");
const connectionString = "EVENT HUBS
NAMESPACE CONNECTION STRING";
const eventHubName = "EVENT HUB NAME";
async function main() {
// Create a producer client to send messages to the event hub.
const producer = new EventHubProducerClient(connectionString, eventHubName);
// Prepare a batch of three events.
const batch = await producer.createBatch();
batch.tryAdd({ body: "First event" });
batch.tryAdd({ body: "Second event" });
batch.tryAdd({ body: "Third event" });
// Send the batch to the event hub.
await producer.sendBatch(batch);
// Close the producer client.
await producer.close();
console.log("A batch of three events have been sent to the event hub");
}
main().catch((err) => {
console.log("Error occurred: ", err);
});
【问题讨论】:
-
请帮助.. 提前致谢