Don't call BasicConsume inside Call method

This commit is contained in:
Ivan Agarsky 2021-08-08 14:47:58 +02:00
parent 08d574812f
commit 12fbf18d9b

View File

@ -34,6 +34,11 @@ public RpcClient()
var response = Encoding.UTF8.GetString(body);
tcs.TrySetResult(response);
};
channel.BasicConsume(
consumer: consumer,
queue: replyQueueName,
autoAck: true);
}
public Task<string> CallAsync(string message, CancellationToken cancellationToken = default(CancellationToken))
@ -52,11 +57,6 @@ public RpcClient()
basicProperties: props,
body: messageBytes);
channel.BasicConsume(
consumer: consumer,
queue: replyQueueName,
autoAck: true);
cancellationToken.Register(() => callbackMapper.TryRemove(correlationId, out var tmp));
return tcs.Task;
}