azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

[BUG] Unable to Create a Service Bus Subscription with Rules

Open azizabah opened this issue 3 years ago • 4 comments

Describe the bug Using the Java SDK, we are not capable of creating a Service Bus Subscription on a topic with rules initially. If you are trying to create a new subscription that would filter on a subset of the data coming to the topic, this is currently not possible without a tiny chance of other data making it onto this subscription because you have follow the following steps:

  • createSubscription()
  • createRule(with filter)
  • deleteRule(for default)

That leaves the potential for messages in a high volume topic to make it to the subscription that shouldn't be there.

Code Snippet

private fun buildSubscriptionWithRules(record: Record) {
        val formattedName = Utils.formatName(record)
        adminClient.createSubscription(configProperties.topic, formattedName, CreateSubscriptionOptions())
        val rule = CreateRuleOptions(SqlRuleFilter("companyId = '${record.company}'"))
        adminClient.createRule(configProperties.topic, "companyFilter", formattedName, rule)
        adminClient.deleteRule(configProperties.topic, formattedName,"\$Default")
    }

Expected behavior I would expect feature parity with the Azure SDK for .NET. https://github.com/Azure/azure-sdk-for-net/blob/5adaf18bf8e50514f6e10110cf74233a7ea56151/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/ServiceBusAdministrationClient.cs#L1927 Notice that you can supply a CreateRuleOptions on creation. This would alleviate the issue.

Setup (please complete the following information):

  • Java/Kotlin 11
  • Spring Boot 2.6.7
  • Azure SDK BOM - 1.1.0
  • com.azure:azure-messaging-servicebus - version powered by BOM

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [X] Bug Description Added

azizabah avatar Jul 08 '22 20:07 azizabah

Thanks for filing this github issue, @azizabah. @ki1729 can you please follow up?

/cc @Azure/azsdk-sb-java

joshfree avatar Jul 11 '22 12:07 joshfree

@ki1729 can you please share an update?

joshfree avatar Aug 23 '22 17:08 joshfree

@azizabah I am working on this feature, and I expect this to be released as part of the SDK release cycle next month

ki1729 avatar Aug 23 '22 17:08 ki1729

@joshfree @ki1729 - Any update on this?

azizabah avatar Sep 20 '22 15:09 azizabah

@azizabah This change is now merged and should be released as part of version 7.13

ki1729 avatar Oct 31 '22 23:10 ki1729

@azizabah This change is now merged and should be released as part of version 7.13

@ki1729 - Can you please link the PR to this issue? Thanks.

azizabah avatar Nov 01 '22 14:11 azizabah

Sure @azizabah. Here is the PR for the issue: https://github.com/Azure/azure-sdk-for-java/pull/31804

ki1729 avatar Nov 01 '22 20:11 ki1729

@azizabah New SDK v7.13 released today supports this capability. Let us know if you have any issues using it.

ki1729 avatar Nov 16 '22 22:11 ki1729

@ki1729 - Will do. Thanks!

azizabah avatar Nov 21 '22 16:11 azizabah