1

I have a Azure Servicebus topie and multiple subscriptions.message will be posted with dictionary type. based on the dictionary key will I be able to filter the message. All the examples are shown based on the hierarchy https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-sql-filter#property_name . here is the payload and I want to filter based on the dict key which is DataReady, Datapending, Dataprocessed.

Message 1:
    {
      "DataReady": "{\"RequestId\":\"605dc8dda700a7b9c25eb22a\"\"Status\":"Initiated\"}"
    }
    
Message 2:
    {
      "DataProcessed": "{\"RequestId\":\"605dc8dda700a7b9c25eb22a\"\"Status\":"Processed\"}"
    }
    
message 3:
    {
      "DataPending": "{\"RequestId\":\"605dc8dda700a7b9c25eb22a\"\"Status\":"pending\"}"
    }
threeleggedrabbit
  • 1,722
  • 2
  • 28
  • 60

1 Answers1

1

Filtering message based on message content is not supported by Azure Service Bus. You can define filtering rules either on the system properties (like id, label etc.) or custom properties (user defined metadata in key/value pair form) of a message only.

Please see this link for examples on setting filtering rules: https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-filter-examples.

One thing you could do is define the status ("Initiated", "Processed" or "Pending") as one of the custom properties (e.g. "MessageStatus") of a message and then you can define the filtering rule on that property.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Thanks, in that case, If I change my dictionary content to { "DataReady": "{\"RequestId\":\"605dc8dda700a7b9c25eb22a\",\"Status\":"Initiated\",\"DataStatus\":"DataReady\"}". Should I be able to filter like DataStatus = DataReady even if its inside the dictionary value? } – threeleggedrabbit Apr 08 '21 at 07:48
  • Nope. Because you’re still trying to filter based on message content which is not allowed. – Gaurav Mantri Apr 08 '21 at 07:51
  • I have added user properties with the status, that resolves the issue. – threeleggedrabbit Apr 12 '21 at 08:20