Azure/azure-event-hubs-node

The sent data to the hub cannot be read from Stream Analytics

michaelnemtsev opened this issue · 6 comments

Describe the bug
I've been using SimpleSender.ts example to send data to an event hub, which were successfully
however, this information cannot be read from Stream Analytics connected to EventHub. Simple action of "Sample Data" returns the error and data is not visibile

It appears that the follow code that sends the event to the hub sends it in the wrong format
const data: EventData = {
body: "Hello World!!"
};
const delivery = await client.send(data);

To Reproduce

  1. Create a new Stream Analytics
  2. Create a new Input job connecting to the existing hub with active data using JSON format
  3. Try "Sample Data" for the new connection using the right timeslot where data exist
  4. Error will be generated that data cannot be read

Expected behavior
The data is read successuflly

Package-name: azure-event-hubs | azure-event-processor-host
Package-version:
node.js version:
OS name and version:

Additional context
Add any other context about the problem here.

I think this is due to the fact that SA expects the payload of the data to be JSON, in the example you've provided it is a string.

Try this instead

const data: EventData = {
body: { "message": "Hello World!!" }
};

Hi @michaelnemtsev thanks for filing the issue. I think stream analytics needs data in json format. So if you send the body asJSON.stringify("Hello World!!") then it should work

We will update our examples with a comment that says for interacting with Stream Analytics make sure that the body property of EventData is a json object.

@SplitThePotCyrus this worked. I appreciate if someone updates the examples accordingly and use {} for the body

This problem is Stream Analytics specific. Eventhubs as a service will accept any type of body for the message. We will document this in our examples to make it clear

All the examples for send, now have a comment to send a JSON object, if the EventHub is being used in conjunction with StreamAnalytics.