Azure / azure-event-hubs-node

Node client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
MIT License
50 stars 46 forks source link

All messages from batch land in the same partition despite different partitionKey used #172

Closed marcinporebski closed 5 years ago

marcinporebski commented 5 years ago

Describe the bug When using batching mechanism along with partitionKey only first message's data is being taken into consideration. All messages from that batch goes to the same partition as the first one.

To Reproduce Send batch of messages with different partitionKey assigned. All messages will be broadcasted with parameters of the first one in batch.

Expected behavior I'd expect that partitionKey is being preserved and I can independently mark partition or partitionKey for each message.

Additional context Actual code that does the over-simplification is here: https://github.com/Azure/azure-event-hubs-node/blob/c677dba0a1da0cebbf996430e0f62a50b3e37595/client/lib/eventHubSender.ts#L302

amarzavery commented 5 years ago

It is as per design. The documentation for sendBatch does mention that

Send a batch of EventData to the EventHub. The "message_annotations", "application_properties" and "properties" of the first message will be set as that of the envelope (batch message).

@sjkwak - Can you please comment on this?

ramya-rao-a commented 5 years ago

Closing this issue as sendBatch can only support sending data to the same partition and this is by design.