Describe the bug
While creating a subscription on a Topic Service Bus with many incoming messages even with disabled status option, messages are received.
To Reproduce
_use a service bus with many activity_
const serviceBusAdminClient = new ServiceBusAdministrationClient(connectionString);
await serviceBusAdminClient.createSubscription(topicName, subscriptionName,{status: 'Disabled'});
await serviceBusAdminClient.deleteRule(topicName, subscriptionName, '$Default' );
// is there messages?
const serviceBusClient = new ServiceBusClient(connectionString);
const subQueue = serviceBusClient.createReceiver(topicName, subscriptionName);
const msg = await subQueue.receiveMessages(1000,
{
receiveMode: "receiveAndDelete",
maxWaitTimeInMs: 500
}
);
if (msg.length){
console.log('Already recived messages:',msg.length);
}
Expected behavior
By setting "Disabled" status we should not have any messages at all.
Thanks for reaching out @xavier-d!
Your sample was helpful, I acknowledge the problem.
We'll check with the service team on the "Disabled" behavior and get back.
I was expecting to use this feature in order get only the messages I want; Create the subscription as Disabled then update the rule as I want. 'SendDisabled' option has been tested and not working either.
Another solution would be to configure the default rule during the subscription creation... but not sure if it is a planned feature
As per the service team, EntityStatus only affects SENDs/ RECEIVEs coming from external clients, messages going from topic to subscriptions are not affected by it.
Another solution would be to configure the default rule during the subscription creation... but not sure if it is a planned feature
For your use case, the only solution as of now would be to add a rule after creation.
According to the service team, configuring the rule while creation is supported, JS SDK needs to add support for the same(TODO).
Hopefully, we'll get to it by the next release.
Also, may I just say a thank you for trying out our previews!
We appreciate the feedback and look forward to hearing anything else in the future
Keeping the issue open to track the feature support.
@xavier-d Meanwhile, if you want to try out the changes, you can use our nightly dev build as well. Install the package using npm install @azure/service-bus@dev. The options for the createSubscription() method now take the default rule options as well.
Disclaimer: Do NOT use the dev build in production :)
It's(dev version) not released yet. I'll ping once done.
Thanks for the dev.
I'll give a try and keep you posted;
The dev version got published 7.0.0-alpha.20201117.3, this version should have the relevant changes to try out.
const adminClient = new ServiceBusAdministrationClient(connectionString);
await adminClient.createSubscription("topic-name", "subscription-name", {
defaultRuleOptions: {
name: "rule-name",
filter: { sqlExpression: "1=2" },
},
});