MassTransit Skipping Messages Sent By Azure Service Bus That Are Published By Azure Devops Service Hook

119 Views Asked by At

I'm trying to consume a message in a .NET WebAPI using MassTrasnit that is sent to an Azure Service Bus resource by an Azure Devops Service Hook that is fired off when a user creates a work item. It looks like I've configured everything right and all the endpoint and topic names line up with each other, but when I try to fire off the service hook, the API picks up that a message was sent to it but MT skips it and puts it in the dead-letter queue. I'm not sure if I need to maybe flesh out my model for my message and that's why it's skipping or what, but I thought I might see if anyone can help me out

This is my configuration of MassTransit in Program.cs

 builder.Services.AddMassTransit(x =>
    {
        x.AddConsumer<WorkItemCreatedConsumer>();

        x.UsingAzureServiceBus((context, cfg) =>
        {
            cfg.Host("[Connection String]");

            cfg.ConfigureEndpoints(context);
        });
    });

This is my message consumer

 public class WorkItemCreatedConsumer : IConsumer<WorkItemCreated>
    {
        private readonly ILogger<WorkItemCreatedConsumer> _logger;

        public WorkItemCreatedConsumer(ILogger<WorkItemCreatedConsumer> logger)
        {
            _logger = logger;
        }

        public Task Consume(ConsumeContext<WorkItemCreated> context)
        {
            _logger.LogInformation("Work Item Created {Message}", context.Message);
            return Task.CompletedTask;
        }
    }

And this is my message model

public class WorkItemCreated
    {
        public string Id { get; set; } = default!;
    }

But when I run my API and everything fires up properly and then I go and set the proper Topic name that is generated in Azure Service Bus in my Azure Service Hook and run a test on it, it skips with this message

[12:43:34 DBG] SKIP sb://test-sample.servicebus.windows.net/WorkItemCreated 646a01b9-24ca-43e1-b3c1-e1d3f459573b
[12:43:36 DBG] Queue: WorkItemCreated_skipped (dead letter)
[12:43:37 INF] MOVE sb://test-sample.servicebus.windows.net/WorkItemCreated 646a01b9-24ca-43e1-b3c1-e1d3f459573b WorkItemCreated_skipped dead-letter

EDIT:

Question was answered by Chris Patterson in the comments, I needed to use the RawJsonDeserializer for non-MT publishers

0

There are 0 best solutions below