0

I'm trying to consume Azure ServiceBus events in an AzureFunction with ServiceBusTrigger using MassTransit. I have 2 functions in the same project, called FunctionA and FunctionB, which should be triggered by events in the same topic but different subscriptions (SubscriptionA, SubscriptionB). Each function is implemented as a separate class. When debugging my application locally using Rider:

  • if I run a single function (either A or B), it is handles events correctly;
  • if I "run all functions", events from subscriptions don't seem to trigger them.

I am new to azure service bus. Am I missing something?

The functions look like this (function B is same, in another class, uses SubcriptionB, calls ConsumerB)

public class ClassA 
{               [FunctionName("FunctionA")]
                public Task Run(
                    [ServiceBusTrigger(
                        "%" + TopicName + "%",
                        "%" + SubscriptionAName + "%",
                        Connection = ConnectionString)]
                    ServiceBusReceivedMessage message,
                    CancellationToken cancellationToken) =>
                    _receiver.HandleConsumer<FunctionAEventConsumer>(
                        _options.TopicName,
                        _options.SubcriptionAName,
                        message,
                        cancellationToken);
            }
        }

Configuration looks essentially like this 

   

     services.AddMassTransitForAzureFunctions(
                cfg =>
                {
                    cfg.AddConsumersFromNamespaceContaining<ConsumerNamespace>();
                },
                ConnectionString,
                (context, configurator) =>
                {
                    
    
                    CreateSubscriptionIfNotExists("SubscriptionA", ConnectionString);
                    CreateSubscriptionIfNotExists("SubscriptionB", ConnectionString);
    });

The CreateSubscriptionIfNotExists method instantiates a new AdministrationClient and creates subscription in the topic if it doesn't exist.

brance
  • 1,157
  • 9
  • 22
AunAun
  • 1,423
  • 2
  • 14
  • 25

0 Answers0