Getting Messages In Skipped Queue

2.4k views Asked by At

Can someone help me understand why I'm getting response messages (CreditAuthorizationResponse) in my skipped queue (mtSubscriber_creditAuthRequest_queue_skipped)? The sender is receiving the responses as expected, but they are also going to the skipped queue.

I've created the following consumer, which is working as expected except for the messages going into the skipped queue:

class CreditAuthorizationConsumer : IConsumer<CreditAuthorizationRequest>
{
    private Func<string, Task> _outputDelegate2;

    public CreditAuthorizationConsumer(Func<string, Task> outputDelegate)
    {
        _outputDelegate2 = outputDelegate;
    } 

    public async Task Consume(ConsumeContext<CreditAuthorizationRequest> context)
    {
        await _outputDelegate2($"Received: {context.Message}: {context.Message.CardNumber}");
        await context.RespondAsync<CreditAuthorizationResponse>(new CreditAuthorizationResponse(true));
        await _outputDelegate2($"Sent CreditAuthorizationResponse for card request {context.Message.CardNumber}");
    }
}

Here is where I'm sending the request:

private async Task SendCreditAuthRequestAsync(int numberToSend)
{
    for (int i = 0; i < numberToSend; i++)
    {
        var cardNumber = generateCardNumber();
        await SendRequestAsync(new CreditAuthorizationRequest(cardNumber), "mtSubscriber_creditAuthRequest_queue");
        await WriteOutputAsync($"Sent credit auth request for card {cardNumber}.");
    }
}

Here is where I'm initializing my client-side bus:

private void InitializeBus()
{
    _messageBus = Bus.Factory.CreateUsingRabbitMq(sbc =>
    {
        var host = sbc.Host(new Uri(hostUriTextBox.Text), h =>
        {
            h.Username("guest");
            h.Password("guest");
        });

        sbc.ReceiveEndpoint(host, "mtSubscriber_creditAuthResponse_queue", endpoint =>
        {
            endpoint.Handler<CreditAuthorizationResponse>(async context =>
            {
                await WriteOutputAsync($"Received: {context.Message}: {context.Message.IsAuthorized}");
            });
        });

    });
}

Here is where I'm initializing my service-side bus:

private void InitializeBus()
{
    _messageBus = Bus.Factory.CreateUsingRabbitMq(sbc =>
    {
        var host = sbc.Host(new Uri(hostUriTextBox.Text), h =>
        {
            h.Username("guest");
            h.Password("guest");
        });

        sbc.ReceiveEndpoint(host, "mtSubscriber_creditAuthRequest_queue", endpoint =>
        {
            endpoint.Consumer(() => new CreditAuthorizationConsumer(WriteOutputAsync)); 
        });
    }
}
1

There are 1 answers

0
scottctr On BEST ANSWER

Alexey Zimarev was right -- my responses were bound to my request queue (in addition to the response queue). Simply deleting that binding resolved the problem and it hasn't come back. thanks!