Azure/azure-event-hubs-node

Coerce patitionKey into a string

sabeegrewal opened this issue · 4 comments

When users set a partitionKey, the library should convert the partitionKey to a type of string. All other libraries in the EventHubs ecosystem expect a string type.

Continuation of:
Azure/azure-event-hubs-spark#424

@sabeegrewal As per your comment in
Azure/azure-event-hubs-spark#424 (comment)

In general, we expect the partitionKey to be a string.

By we, I am assuming you are referring to the Event Hubs service itself. Right?

Seems that the node.js library should coerce partitionKeys into string types.

What I am worried about here is breaking existing customers by making this change especially if they rely on the partitionKey being used as is. Can you elaborate on how exactly is partitionKey used by Event Hubs?

When the passed value is not a string, does Event Hubs ignore it? Now, if we start converting the given value to string, will that change the behavior regarding which partition the data gets sent to?

@sjkwak can speak to this more.

Yea, the service and all statically-typed clients treat partitionKey as a string.

Thanks @sabeegrewal

We learnt that by converting user provided partitionKey to a string, a user who has been using a non string partition key will now have their messages sent to a totally new partition. This is a breaking change especially if the partition id provided when they are receiving messages are hard-coded.

We are leaning towards throwing an error message in such cases and make a major version update.
This way the experience for existing customers won't change unless they opt in to a new major version.

We have just released a new version 2.0.0 for the Event Hubs library which includes the change to throw an error if a message is being set with a partitionKey which is not a string.