MassTransit 添加自定义的 RabbitMQ 客户端属性

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

MassTransit Add custom RabbitMQ client properties

问题

在使用 MassTransit 时,是否可以添加自定义的客户端属性,以便在 RabbitMQ 中的连接上使用?

我唯一成功的是添加了自定义提供的连接名称,该名称会显示在连接概述中:

MassTransit 添加自定义的 RabbitMQ 客户端属性

可以使用以下方式实现这一点:

x.UsingRabbitMq((context, cfg) =>
{
    cfg.Host(RabbitMQHost, RabbitMQPort, "/", "MyCustomConnectioName", h =>
    {
        h.Username(RabbitMQUser);
        h.Password(RabbitMQPass);
    });
});

我希望能在这里添加一些额外的元数据:

MassTransit 添加自定义的 RabbitMQ 客户端属性

我找到了大部分信息设置的代码行,但不知道如何与它进行交互,如果可能的话。

链接如下:
https://github.com/MassTransit/MassTransit/blob/6f6d8f479233a084af1048204558bf459d249738/src/Transports/MassTransit.RabbitMqTransport/RabbitMqTransport/RabbitMqAddressExtensions.cs#L84

我也看到了这个,但那是为消费者配置的:

https://stackoverflow.com/questions/65148041/add-metadata-when-configuring-an-endpoint-to-be-delivered-in-the-consumer

英文:

When using MassTransit, is it possible to add your own / custom Client properties which are available on Connections in RabbitMQ?

The only thing I managed is a custom provided connection name, which does appear in the connections overview:

MassTransit 添加自定义的 RabbitMQ 客户端属性

With this:

x.UsingRabbitMq((context, cfg) =>
{
    cfg.Host(RabbitMQHost, RabbitMQPort, "/", "MyCustomConnectioName", h =>
    {
        h.Username(RabbitMQUser);
        h.Password(RabbitMQPass);
    });
});

What I would like is some extra metadata over here:

MassTransit 添加自定义的 RabbitMQ 客户端属性

Did found the line where most of this info is set, but I don't know how to interact with that, if possible.

https://github.com/MassTransit/MassTransit/blob/6f6d8f479233a084af1048204558bf459d249738/src/Transports/MassTransit.RabbitMqTransport/RabbitMqTransport/RabbitMqAddressExtensions.cs#L84

Also saw this one, but that is for the Consumer:

https://stackoverflow.com/questions/65148041/add-metadata-when-configuring-an-endpoint-to-be-delivered-in-the-consumer

答案1

得分: 1

唯一可以设置的是连接名称,我认为没有任何允许设置其他属性的便利性。

英文:

The only thing that can be set is the connection name, I don't believe there is any affordance to allow other properties to be set.

huangapple
  • 本文由 发表于 2023年7月20日 13:24:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76726895.html
  • c#
  • masstransit
  • rabbitmq

List: 如何为某个索引元素应用“where”条件? go 66
匿名

发表评论

匿名网友

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

确定

  • 开发者交流平台

    本页二维码