Raas Masood
Raas Masood

Reputation: 1575

Azure Service bus topic trigger not hitting breakpoint

i am trying to read messages sent to a Topic using a trigger like this

   private readonly LogEvent _eventLogger;


    public EventMonitoring(LogEvent eventLogger)
    {
        _eventLogger = eventLogger;
    }
    [FunctionName("EventMonitoring")]
    public async Task Run([ServiceBusTrigger(
            "cta-event-monitoring",
            "monitoring",
            Connection = "ServiceBusConnectionString",
            IsSessionsEnabled = true)]string mySbMsg, ILogger log)
    {

        log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
    }
}

and i have a console application that sends a text to same topic and subscription.

    public class Program
{
    static string connectionString = "Endpoint=sb://cta-servicebus-dev.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=QAmJvBkxxxxxxxxxxxxxxxxxxxxxxxxxx";
    static string topicName = "cta-event-monitoring";
    static string subscriptionName = "monitoring";
    static  void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
        AsyncContext.Run(() => SendMessageToTopicAsync());
    }
    static async Task SendMessageToTopicAsync()
    {
        // create a Service Bus client 
        await using (ServiceBusClient client = new ServiceBusClient(connectionString))
        {
            // create a sender for the topic
            ServiceBusSender sender = client.CreateSender(topicName);
            await sender.SendMessageAsync(new ServiceBusMessage("Hello, World!"));
            Console.WriteLine($"Sent a single message to the topic: {topicName}");
        }
    }
}

when i send the message they end up in dead-letter and break point is not hit. i also tried publishing the function app and test it using TEST/RUN feature it kind of works

enter image description here

what am is missing in order to hit the breakpoint ?

deployed version is also turned of.

uPDATE i have 2 subscriptions now. one has sessions active another one is sessions in active. when i send something to the topic it lands in deadletter for the subscriptions with topic and it lands in active message for the subscrition without session.

if i try to point my servicebus topic trigger to subscription without sessions in get

A sessionful message receiver cannot be created on an entity that does not require sessions.

Upvotes: 0

Views: 402

Answers (1)

Raas Masood
Raas Masood

Reputation: 1575

it was a simple miss. i had to set IsSessionsEnabled to false since i didn't set it up while creating the subscription.

Upvotes: 2

Related Questions