filip
filip

Reputation: 1503

Set partitionKey for the event hub output binding

I have a javascript function app, which defines output binding pointing to an Event Hub as described here. I'm sending multiple messages at once (in batch) to ensure best performance:

var message1 = //create javascript object here
var message2 = //create javascript object here
(...)

context.bindings.outputEventHubMessage = [];
context.bindings.outputEventHubMessage.push(message1);
context.bindings.outputEventHubMessage.push(message2);
(...)

context.done();

That works, but I'd like to set the partition key on the message level, to ensure that messages with the same partition key end up in the same EH partition. I tried following:

message1.partitionKey = "ABC";
message2.partitionKey = "ABC";

...but it didn't work - for large amount of messages I've noticed that messages with the same partition key had different partition IDs.

Is this doable when sending in batches? If not, would that work when sending 1-by-1?

Upvotes: 1

Views: 1228

Answers (1)

PramodValavala
PramodValavala

Reputation: 6647

Based on this discussion, looks like its not possible with the way the binding works today. Though the discussion is about C#, the same would apply for other languages well.

Considering the change in the Event Hubs SDK, at-least for C#, there seems to be an option by binding to the EventHubClient directly. But this won't be possible for other languages.

The workaround would be to directly use the Azure Event Hubs NodeJS SDK instead of using the binding.

Upvotes: 1

Related Questions