有人可以帮我理解为什么我在跳过的队列中收到响应消息(CreditAuthorizationResponse)(mtSubscriber_creditAuthRequest_queue_skipped)?发件人正在按预期收到响应,但他们也会转到跳过的队列。
我创建了以下使用者,除了进入跳过队列的消息之外,它正在按预期工作:
some_foo.many_objects.each(&:destroy)
# ... other code, not knowing about the earlier 'destroy' call(s)
some_foo.many_objects.empty?
# => true
这是我发送请求的地方:
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}");
}
}
这是我正在初始化客户端总线的地方:
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}.");
}
}
这是我正在初始化服务端总线的地方:
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}");
});
});
});
}
答案 0 :(得分:0)
Alexey Zimarev是对的 - 我的回复绑定到我的请求队列(除了响应队列)。简单地删除该绑定解决了问题并且它没有回来。谢谢!