Azure / azure-service-bus

☁️ Azure Service Bus service issue tracking and samples
https://azure.microsoft.com/services/service-bus
MIT License
586 stars 779 forks source link

Correlation filter for custom properties not working when filtering on number #401

Open johannesoenema opened 3 years ago

johannesoenema commented 3 years ago

Description

For a subscription I was changing the sql filters to correlation filters, since they were using equality only. I ran into some issues when the filter value is a number.

On the message we have a custom property version. This version should be 2.

Steps to reproduce

Create the filter in the portal. image

Send a message using the portal (the problem happens as well if the message is sent with code). image

Actual Behavior

  1. Active message count stays 0.

Expected Behavior

  1. Active message count becomes 1.

This doesn't seem expected behavior. Could you look into this?

SeanFeldman commented 3 years ago

@johannesoenema, does it work if you send a message with the custom property version set to a string value ("2")?

johannesoenema commented 3 years ago

@SeanFeldman Yes, that works! Somehow, I would expect that it treats it as a string or that it would compare integers. Adding extra double quotes (single quotes don't work) is not very intuitive.

I understand now reading this article that the custom properties are a dictionary of string and object, so it supports more than just strings. Am I right, that correlation filters only support strings? Maybe that is a good addition to the documentation.

So my options are: use a correlation filter with "2" as value or use a sql filter?

SeanFeldman commented 3 years ago

So my options are: use a correlation filter with "2" as value or use a sql filter?

Sounds right. Correlation filters are supposed to be very efficient and fast. Would not be surprised if the assumption is made for the values to be strings only. @axisc, would it be possible to validate that and update the documentation?

johannesoenema commented 3 years ago

Thanks for your quick response. Would be a nice feature to have int comparison available as well. If we would change it to "2", someone else can't use > 2 in a sql filter anymore. But I guess you are right about the efficiency part.

A match exists when an arriving message's value for a property is equal to the value specified in the correlation filter. For string expressions, the comparison is case-sensitive. (Source: https://docs.microsoft.com/en-us/azure/service-bus-messaging/topic-filters)

For string expressions seems to suggest that there are other comparisons possible. If that isn't the case, then it could use some clarification.

EldertGrootenboer commented 2 years ago

Just tested this, and this does seem to work now.

image

image

one-random-dev commented 6 months ago

Seems like this problem resurfaced

We can easily recreate the issue on the portal only, when setting up a Correlation Filter there is no option of the custom property type to filter for When we send a message we have to select a custom Property Type This way makes it impossible to configure a integer filter on Azure Portal

Even when configured by the python sdk where the filter gets the Custom Property set as Integer, it will not filter the messages through when the condition matches

EldertGrootenboer commented 6 months ago

We have added a backlog item to allow to set the data type from the portal when creating a correlation filter. We will update this thread once we have more to share on our progress. For now, we recommend creating these filters through the SDK if a non-string data type is needed, this was just tested with the .NET SDK and this works.

As for the python SDK, if this doesn't work there, please open an issue on https://github.com/Azure/azure-sdk-for-python/issues, as this would be an issue with that SDK.