Fixed body corruption in Tapeti.Cmd shovel command

This commit is contained in:
Mark van Renswoude 2021-08-24 13:18:53 +02:00
parent 51ebfd62b4
commit 2eb66c5780
1 changed files with 5 additions and 1 deletions

View File

@ -22,10 +22,14 @@ namespace Tapeti.Cmd.Commands
// No more messages on the queue
break;
// Since RabbitMQ client 6 we need to copy the body before calling another channel method
// like BasicPublish, or the published body will be corrupted
var bodyCopy = result.Body.ToArray();
rateLimiter.Execute(() =>
{
targetChannel.BasicPublish("", TargetQueueName, result.BasicProperties, result.Body);
targetChannel.BasicPublish("", TargetQueueName, result.BasicProperties, bodyCopy);
messageCount++;
if (RemoveMessages)