ServiceBusExplorer icon indicating copy to clipboard operation
ServiceBusExplorer copied to clipboard

Correlation filter does not allow any messages through

Open ArchiFloyd opened this issue 1 year ago • 4 comments

Hi!

First and foremost, thank you for the awesome work on service bus explorer. It's a really helpful tool.

I experience that when trying to create a correlation filter marked as the default filter using service bus explorer, no messages are allowed through the filter. If I create the same correlation filter on a subscription through some quick and dirty C# code it allows messages.

The correlation filter I'm trying to create looks like this: image

I've observed the issue in the following versions: 5.0.18 6.0.2

I'm not sure what more to include here.

ArchiFloyd avatar Jul 09 '24 06:07 ArchiFloyd

@ArchiFloyd are these the stesps to repro?

  1. Create a subscription with a correlation filter (Property1 == 47381)
  2. Publish messages to the topic with the Property1 set to 47381
  3. Inspect the subscription for the messages

If I create the same correlation filter on a subscription through some quick and dirty C# code it allows messages.

Just to be on the same page, could you share the custom C# code used?

SeanFeldman avatar Jul 09 '24 09:07 SeanFeldman

Thank you for the quick reply. I couldn't find a way to directly create a subscription with a correlation filter immediately. So steps are:

  1. Create a new Subscription
  2. Delete the default rule
  3. Create new rule having the correlation filter with Property1 = 47381
  4. Inspect the subscription for messages.

My hack-ish C#:

var filter = new CorrelationRuleFilter { ApplicationProperties = { ["Property1"] = 47381 } };
var ruleOptions = new CreateRuleOptions { Filter = filter };
var topic = "testtopic"
var subscription = "testsub"

var doesTopicExist = await serviceBusAdministrationClient.TopicExistsAsync(
    topic,
    cancellationToken);

if (doesTopicExist.HasValue
    && doesTopicExist.Value)
{
    var doesSubscriptionExist = await serviceBusAdministrationClient.SubscriptionExistsAsync(
        topic,
        subscription,
        cancellationToken);

    if (doesSubscriptionExist.HasValue
        && !doesSubscriptionExist.Value)
    {
        await serviceBusAdministrationClient.CreateSubscriptionAsync(
            new CreateSubscriptionOptions(
                topic,
                subscription)
            {
                RequiresSession = true
            },
            ruleOptions ?? new CreateRuleOptions(),
            cancellationToken);
    }
}

ArchiFloyd avatar Jul 09 '24 09:07 ArchiFloyd

I suspect the filter is working with a string value rather than numeric. Send the property value as a string "47381" and you'll see it working. This could be a bug with SBE that doesn't know how to work with numeric value.

SeanFeldman avatar Jul 09 '24 10:07 SeanFeldman

In my case I'm not in control of the producer of the messages, thus, cannot change how it behaves. My consumer is working with the subscription and filter created in C# which is fine to me. Let me know if you need anything from me. I can try to reproduce your findings if need be @SeanFeldman.

ArchiFloyd avatar Jul 09 '24 12:07 ArchiFloyd