From 01053b1a845d47acac80ab76f964ae9104ec0d8c Mon Sep 17 00:00:00 2001 From: Henery309 <59211495+Henery309@users.noreply.github.com> Date: Thu, 24 Sep 2020 02:18:09 +1200 Subject: [PATCH] Set correlation Id for azure service bus message (#673) * Update TransportMessage.cs Added GetCorrelationId to TransportMessage * Update ITransport.AzureServiceBus.cs Set CorrelationId for Microsoft.Azure.ServiceBus.Message --- .../ITransport.AzureServiceBus.cs | 5 +++-- src/DotNetCore.CAP/Messages/TransportMessage.cs | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/DotNetCore.CAP.AzureServiceBus/ITransport.AzureServiceBus.cs b/src/DotNetCore.CAP.AzureServiceBus/ITransport.AzureServiceBus.cs index 763e381..fbac724 100644 --- a/src/DotNetCore.CAP.AzureServiceBus/ITransport.AzureServiceBus.cs +++ b/src/DotNetCore.CAP.AzureServiceBus/ITransport.AzureServiceBus.cs @@ -42,7 +42,8 @@ namespace DotNetCore.CAP.AzureServiceBus { MessageId = transportMessage.GetId(), Body = transportMessage.Body, - Label = transportMessage.GetName() + Label = transportMessage.GetName(), + CorrelationId = transportMessage.GetCorrelationId() }; foreach (var header in transportMessage.Headers) @@ -86,4 +87,4 @@ namespace DotNetCore.CAP.AzureServiceBus } } } -} \ No newline at end of file +} diff --git a/src/DotNetCore.CAP/Messages/TransportMessage.cs b/src/DotNetCore.CAP/Messages/TransportMessage.cs index c4f7fa7..80c1fe7 100644 --- a/src/DotNetCore.CAP/Messages/TransportMessage.cs +++ b/src/DotNetCore.CAP/Messages/TransportMessage.cs @@ -43,5 +43,10 @@ namespace DotNetCore.CAP.Messages { return Headers.TryGetValue(Messages.Headers.Group, out var value) ? value : null; } + + public string GetCorrelationId() + { + return Headers.TryGetValue(Messages.Headers.CorrelationId, out var value) ? value : null; + } } }