Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Sending to Event Hub

$
0
0

I don't know what's wrong with this node.js code.  I don't get any error messages, but I can't see the messages in Event Hub.  I'm able to send the same payload / keys from Python to the same EventHub without issue.  Any suggestions?

const { EventHubClient } = require("@azure/event-hubs");
// Connection string - primary key of the Event Hubs namespace.
const connectionString = "Endpoint=sb://sensor-partner-eh-namespace-cfrlr.servicebus.windows.net/;SharedAccessKeyName=XXX;SharedAccessKey=XXX;";
// Name of the event hub. For example: myeventhub
const eventHubsName = "sensor-partner-eh-03";
// Open Payload File
const payload = require("./payload.json");
async function main() {
  const writeclient = EventHubClient.createFromConnectionString(connectionString, eventHubsName);
  for (let i = 0; i < 100; i++) {
    var eventData = payload;
    console.log(JSON.stringify(eventData,null,4));
    await writeclient.send(eventData,0);
  }
  await writeclient.close();
}
main().catch(err => {
  console.log("Error occurred: ", err);
});


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>