I have just started learning Masstransit and I would like to ask you one query on the accepted answer in this post. Here I have the same problem where consumer does not get the message. May be I have made some mistake or misunderstood some basic concept.
What I did:
Create a Topic in Azure service bus
Create a Subscription for the Topic
Send message into the topic as per the suggestion here. I can see from Azure portal that the message has been added into the Topic successfully.
Now I'm trying to consume the message by using the below code:
private static async Task SetupMassTransit() { var services = new ServiceCollection(); services.AddMassTransit(x => { x.AddConsumer<MessageConsumer>(); //Consumer class x.UsingAzureServiceBus((context, cfg) => { cfg.Host(ServiceBusConnectionString); // https://stackoverflow.com/questions/64229653/receiver-not-picking-up-message-with-mass-transit-subscription cfg.SubscriptionEndpoint(TopicName, SubscriptionName, e => { e.PrefetchCount = 100; e.MaxConcurrentCalls = 100; e.LockDuration = TimeSpan.FromMinutes(5); e.MaxAutoRenewDuration = TimeSpan.FromMinutes(30); e.UseMessageRetry(r => r.Intervals(100, 200, 500, 800, 1000)); e.UseInMemoryOutbox(); e.ConfigureConsumer<MessageConsumer>(context); }); }); }); var provider = services.BuildServiceProvider(); IBusControl busControl = provider.GetRequiredService<IBusControl>(); busControl.Start(); }
I am expecting that the 'Consume' function should be called when I run the consumer project. But it does not. Also it creates fault topic though I'm unable to read it through Fault consumer.
public class MessageConsumer : IConsumer<SendMessage> { public Task Consume(ConsumeContext<SendMessage> context) { Console.WriteLine($"Message processed: SequenceNumber:{context.Message.customerId} - Text:{context.Message.messages}"); return Task.CompletedTask; } }
Please note: The consumer and Producer use the same message object (i.e. inside same namespace)
Could you please tell me where actually I make the mistake? In advance thanks