关联 ID 在 MassTransit 和 Azure 服务总线中缺少破折号

huangapple go评论49阅读模式
英文:

Correlation Id missing dashes with MassTransit and Azure Service Bus

问题

在使用 MassTransit 和 Azure Service Bus 时,消息中的关联 ID Guid 值会被移除破折号。

这是我们设置关联 ID 的方式,根据文档

services.AddMassTransit(x =>
{
    MessageCorrelation.UseCorrelationId<MyMessage>(x => Guid.NewGuid());
    x.AddConsumer<...Consumer>();
    x.UsingAzureServiceBus((IBusRegistrationContext context, IServiceBusBusFactoryConfigurator cfg) =>
    {
        cfg.Host(config.AzureServiceBus.ConnectionString);               
        // 其他配置...
    }
}

我们使用 MassTransit 的 NuGet 版本是 v8.0.6,但尝试使用 8.0.12 也没有帮助。

我在 masstransit 的 GitHub 仓库 中没有找到与此相关的已报告问题。

看起来像是一个 bug,因为我无法想出任何原因为什么应该移除破折号。

英文:

Dashes are removed from the correlation id Guid value in messages while using MassTransit and Azure Service Bus.

Here is how we set the correlation id, which is according to the documentation:

services.AddMassTransit(x =&gt;
{
      MessageCorrelation.UseCorrelationId&lt;MyMessage&gt;(x =&gt; Guid.NewGuid());
     x.AddConsumer&lt;...Consumer&gt;();
     x.UsingAzureServiceBus((IBusRegistrationContext context, IServiceBusBusFactoryConfigurator cfg) =&gt;
     {
          cfg.Host(config.AzureServiceBus.ConnectionString);               
          ....
     }
}

关联 ID 在 MassTransit 和 Azure 服务总线中缺少破折号

We are on MassTransit nuget v8.0.6 but trying with 8.0.12 didn't help.

I have not found any reported issues related to this on masstransit github repo.

It seems like a bug as I cannot think of any reason why dashes should be removed.

答案1

得分: 2

I found it here by searching the MassTransit code:

if (context.CorrelationId.HasValue)
    message.CorrelationId = context.CorrelationId.Value.ToString("N");

So indeed, it seems like the developers chose that particular format on purpose.

英文:

I found it here by searching the MassTransit code:

if (context.CorrelationId.HasValue)
    message.CorrelationId = context.CorrelationId.Value.ToString(&quot;N&quot;);

So indeed, it seems like the developers chose that particular format on purpose.

huangapple
  • 本文由 发表于 2023年2月17日 23:55:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75486524.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定