0
votes

In my ASP.NET core controller, I send a command using IMediator.Send

await mediator.Send(new SubmitOrder());

The consumer of the SubmitOrder looks like this

public class SubmitOrderConsumer : IConsumer<SubmitOrder>
{
    public async Task Consume( ConsumeContext<SubmitOrder> context )
    {
        var sendEndpoint = await context.GetSendEndpoint( new Uri( "rabbitmq://localhost/notification-service" ) );
        await sendEndpoint.Send( new NotifyOrderSubmitted() );
    }
}

Sending a message to a transport results in a error message

MassTransit.MessageNotConsumedException: 'loopback://localhost/mediator => The message was not consumed'

Publishing a doest add a message on to RabbitMQ

Is there a way to do this with the ConsumeContext rather than injecting IBusControl or IBus as i would like to keep the context of the message thread

1

1 Answers

0
votes

When consuming messages within Mediator, the interfaces are all mediator-related. To jump the tracks from mediator to the bus, you'd need to reference the bus (via IBus) via dependency injection to the consumer.