Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail using Azure ServiceBus Topic from Framework 4.5.1

Tags:

servicebus

my client is WebForm running on framework 4.5.1 (using Microsoft.ServiceBus 1_1, and my server is .netcore running on azure.

the servicebus is running on azure.

my problem started when the client is running, trying to connect to a subscriber but get an exception cause the subscriber does not exists yet(which is a valid scenario causer the server might not send a notification yet).

so, i try to check if there is a subscriber and create it if not exists. when I try to create the subscription from the client it gives me an error: The incoming request is not recognized as a namespace policy put request.

creating a subscription from the server works.

Client code:

var name = NamespaceManager.CreateFromConnectionString(serviceBusConnectionString);

        if (!name.SubscriptionExists(topicName, subscription))
        {
            SubscriptionDescription sd = new SubscriptionDescription(topicName, subscription);
            RuleDescription rd = new RuleDescription("filter1", new SqlFilter($"sys.To={subscription_managerId}"));
            name.CreateSubscription(sd, rd); // fail here
        }
        _subscriptionClient = SubscriptionClient.CreateFromConnectionString(serviceBusConnectionString, topicName, subscription, ReceiveMode.ReceiveAndDelete);

any idea? thanks for all the helpers

like image 967
OriH Avatar asked Apr 19 '26 19:04

OriH


1 Answers

For anyone facing the same problem, it seems there may be more than one cause but, in my case, the topic hadn't yet been created.

So the trick was to ensure the topic is in place before proceeding.

like image 115
Fabio Milheiro Avatar answered Apr 27 '26 18:04

Fabio Milheiro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!