Azure / azure-sdk-for-node

Azure SDK for Node.js - Documentation
https://github.com/Azure/azure-sdk-for-node#documentation
MIT License
1.19k stars 567 forks source link

Service Bus Subscription Rules - Missing support for CorrelationFilters with an arbitrary field #5200

Closed mcijsouw closed 4 years ago

mcijsouw commented 4 years ago

In my project I'm creating a Service Bus topic subscription programmatically:

serviceBusService.createSubscription('myTopic', 'mySubscription')

Then I would like to add a rule to filter all messages by a specific TenantId.

The documentation on https://docs.microsoft.com/en-us/azure/service-bus-messaging/topic-filters states that you can match against any user-defined property with a CorrelationFilter. However, the library does not support this. Looking at https://github.com/Azure/azure-sdk-for-node/blob/master/lib/services/serviceBus/lib/models/ruleresult.js the only options are:

The last option correlationIdFilter is not suitable for my needs since it filters on CorrelationId.

I would like to add a correlationFilter where I can specify both the key and the value. Can you add this to the library? Something like this:

serviceBusService.createRule('myTopic', 'mySubscription', 'tenantIdFilter', {
  correlationFilter: {
    key: 'TenantId',
    value: 'my-tenant-id'
  }
});

Possible (not desired) workaround:

As a workaround I could use { sqlExpression: "TenantId = 'my-tenant-id'" }, but the documentation states the following: "Whenever possible, applications should choose correlation filters over SQL-like filters because they're much more efficient in processing and have less impact on throughput."

qiaozha commented 4 years ago

@ramya-rao-a Is this for data plane SDK?

ramya-rao-a commented 4 years ago

@qiaozha Yes, this is for the azure-sb package.

@mcijsouw We are working on a new library for Service Bus, where you should be able to use the correlation filter with user defined properties on the message. The azure-sb package will soon be deprecated in favor of the new library and will not be getting any new features.

Please give the new library a try. You can install it using npm install @azure/service-bus@next. The latest preview version at this moment is 7.0.0-preview.8 We will be publishing the stable version for this in this month.

ramya-rao-a commented 4 years ago

And here is the sample that shows how you would use the ServiceBusAdministrationClient in the new package to create queues/topics/subscription. You can use the same client to create rules as well