rebus-org / Rebus.AzureServiceBus

:bus: Azure Service Bus transport for Rebus
https://mookid.dk/category/rebus
Other
33 stars 20 forks source link

Subscription is not getting registered under topic after using custom topic name in azure service bus #83

Closed kanu-dhakhada closed 2 years ago

kanu-dhakhada commented 2 years ago

Publisher code:

                 var configurer = Configure.With(new CastleWindsorContainerAdapter(container))
                  .Options(o =>
                  {
                      o.SpecifyOrderOfHandlers().First<AuthenticationHandler>();
                      o.SetNumberOfWorkers(RebusConfigSettings.Workers);
                      o.SetMaxParallelism(RebusConfigSettings.Workers);
                      o.SimpleRetryStrategy(maxDeliveryAttempts: RebusConfigSettings.RetryAttempts);
                  })
                  .Logging(l => l.Log4Net())
                  .Routing(r => r.TypeBasedRoutingFromAppConfig())
                  .Sagas(m => m.StoreInNDb())
                  .Events(e =>
                  {
                      e.BeforeMessageSent += (bus, headers, message, context) =>
                      {
                          if (RebusConfigSettings.TimeToBeReceived != "-1")
                          {
                              headers.Add(Headers.TimeToBeReceived, RebusConfigSettings.TimeToBeReceived);
                              headers.Add(Headers.Express, "rebus-express");
                          }
                      };
                  });
                  string azureServiceBusUrl = EnvironmentVariablesManager.GetEnvironmentVariable("AzureServiceBusUrl");
                    if (!string.IsNullOrWhiteSpace(azureServiceBusUrl))
                    {
                        configurer.Options(o => o.UseShortTopicNames())
                        .Transport(t => t.UseAzureServiceBus(azureServiceBusUrl, 
                       RebusConfigSettings.InputQueue).AutomaticallyRenewPeekLock()).Start();
                    }

Note: I have referred your post to implement custom topic name (Post)

Subscriber code:

                    var configurer = Configure.With(new CastleWindsorContainerAdapter(container))
                    .Options(o =>
                    {
                        o.SetNumberOfWorkers(RebusConfigSettings.Workers);
                        o.SetMaxParallelism(RebusConfigSettings.Workers);
                        o.SimpleRetryStrategy(maxDeliveryAttempts: RebusConfigSettings.RetryAttempts);
                    })
                    .Logging(l => l.Log4Net())
                    .Routing(r => r.TypeBasedRoutingFromAppConfig())
                    .Events(e =>
                    {
                        e.BeforeMessageSent += (bus, headers, message, context) =>
                        {
                            if (RebusConfigSettings.TimeToBeReceived != "-1")
                            {
                                headers.Add(Headers.TimeToBeReceived, RebusConfigSettings.TimeToBeReceived);
                                headers.Add(Headers.Express, "rebus-express");
                            }
                        };
                    });
                   string azureServiceBusUrl = EnvironmentVariablesManager.GetEnvironmentVariable("AzureServiceBusUrl");
                   if (!string.IsNullOrWhiteSpace(azureServiceBusUrl))
                       configurer.Transport(t => t.UseAzureServiceBus(azureServiceBusUrl, 
                   RebusConfigSettings.InputQueue).AutomaticallyRenewPeekLock()).Start();

If we removed configurer.Options(o => o.UseShortTopicNames()) then it is working fine! but in our case, we need to use custom topic name for multi-tenant purpose so need to append environment id for each tenant.

Version info: .Net framework: 4.7.2 Rebus: 5.3.1.0 Azure Service bus: 3.0.0.0

mookid8000 commented 2 years ago

Could you maybe update your Rebus packages (especially Rebus.AzureServiceBus) to something more recent.

If you're using Rebus.AzureServiceBus 3.0.0, you're running with a package that is more than 5 years old. As an open source maintainer, I have only a limited time available to maintaining software, so it's simply not possible for me to provide support to packages that old.

I'll close this issue now, but feel free to continue the discussion in here if you hit a snag while updating.

Thanks for your understanding. 🙂

kanu-dhakhada commented 2 years ago

Totally agree on the same, we have planned to upgrade version to latest version, but for now I have resolved issue, it was due to subscription name length was too long (more than 50 characters), due to that it was failing to register subscription under topic.

Thank you!