From 9fa293c892dbc272e64c01abbce26b65fbd66599 Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Mon, 15 May 2023 22:34:33 -0500 Subject: [PATCH] Fixed? #4364 Handle InvalidOperationException when a message is already being canceled by Azure Service Bus --- .../ServiceBusSendTransportContext.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Transports/MassTransit.Azure.ServiceBus.Core/AzureServiceBusTransport/ServiceBusSendTransportContext.cs b/src/Transports/MassTransit.Azure.ServiceBus.Core/AzureServiceBusTransport/ServiceBusSendTransportContext.cs index 187f1dfa174..ffc21c8857c 100644 --- a/src/Transports/MassTransit.Azure.ServiceBus.Core/AzureServiceBusTransport/ServiceBusSendTransportContext.cs +++ b/src/Transports/MassTransit.Azure.ServiceBus.Core/AzureServiceBusTransport/ServiceBusSendTransportContext.cs @@ -148,6 +148,10 @@ async Task CancelScheduledSend(SendEndpointContext clientContext, Guid tokenId, { MassTransit.LogContext.Debug?.Log("CANCEL {DestinationAddress} {TokenId} message not found", EntityName, tokenId); } + catch (InvalidOperationException exception) when (exception.Message.Contains("already being cancelled")) + { + MassTransit.LogContext.Debug?.Log("CANCEL {DestinationAddress} {TokenId} message already being canceled", EntityName, tokenId); + } } static bool IsCancelScheduledSend(AzureServiceBusSendContext context, out Guid tokenId, out long sequenceNumber)