From 8a28090edfc1088eb83712e752129fc37cef8d6d Mon Sep 17 00:00:00 2001 From: Michael Fyffe <6224270+TraGicCode@users.noreply.github.com> Date: Thu, 18 Dec 2025 10:52:04 -0600 Subject: [PATCH] Fix issue on graceful shutdown with rabbitmq due to not copying memory for the message body --- src/BuslyCLI.Console/Commands/Command/SendCommand.cs | 3 +-- src/BuslyCLI.Console/Commands/Event/PublishCommand.cs | 3 +-- src/BuslyCLI.Console/Factories/RawEndpoint.cs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/BuslyCLI.Console/Commands/Command/SendCommand.cs b/src/BuslyCLI.Console/Commands/Command/SendCommand.cs index 1094394..15aef63 100644 --- a/src/BuslyCLI.Console/Commands/Command/SendCommand.cs +++ b/src/BuslyCLI.Console/Commands/Command/SendCommand.cs @@ -40,8 +40,7 @@ await rawEndpoint.Dispatch( new TransportTransaction() ); - // TODO: Figure out why this causes connection closed errors with rabbitmq - // await rawEndpoint.ShutDownAndCleanUp(); + await rawEndpoint.ShutDownAndCleanUp(); return 0; } diff --git a/src/BuslyCLI.Console/Commands/Event/PublishCommand.cs b/src/BuslyCLI.Console/Commands/Event/PublishCommand.cs index f0896d8..c8bc3bd 100644 --- a/src/BuslyCLI.Console/Commands/Event/PublishCommand.cs +++ b/src/BuslyCLI.Console/Commands/Event/PublishCommand.cs @@ -45,8 +45,7 @@ await rawEndpoint.Dispatch( new TransportTransaction() ); - // TODO: Figure out why this causes connection closed errors with rabbitmq - // await rawEndpoint.ShutDownAndCleanUp(); + await rawEndpoint.ShutDownAndCleanUp(); return 0; } diff --git a/src/BuslyCLI.Console/Factories/RawEndpoint.cs b/src/BuslyCLI.Console/Factories/RawEndpoint.cs index 981a2a1..dc6d4ae 100644 --- a/src/BuslyCLI.Console/Factories/RawEndpoint.cs +++ b/src/BuslyCLI.Console/Factories/RawEndpoint.cs @@ -66,7 +66,7 @@ await _subscriptionManager.SubscribeAll([new MessageMetadata(CreateTypeFromStrin public Task OnMessage(MessageContext messageContext, CancellationToken cancellationToken) { _receivedMessages.Add( - new IncomingMessage(messageContext.NativeMessageId, messageContext.Headers, messageContext.Body), + new IncomingMessage(messageContext.NativeMessageId, messageContext.Headers, messageContext.Body.ToArray()), cancellationToken); return Task.CompletedTask; }