I've done quite a bit of searching but I can't find a definitive answer to this question. I also can't find anything in the documentation that makes it absolutely clear (to me).
Is it safe to call BasicAck
/BasicReject
on multiple different threads, potentially at the same time?
An example:
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (sender, ea) =>
{
_ = Task.Run(async () =>
{
// simulate processing time
await Task.Delay(rand.Next(2000, 10001));
// send acknowledgement
channel.BasicAck(ea.DeliveryTag, false);
});
}
If the answer is no, what is the correct way to concurrently process multiple messages from the queue, and acknowledge as processing completes?