简体   繁体   English

MassTransit自定义MessageType名称

[英]MassTransit Custom MessageType Name

We've been using MassTransit to act as a ServiceBus between our microservices. 我们一直在使用MassTransit充当微服务之间的ServiceBus。

We have on microservice in python and the other in .Net, in this case the python service publish a message like so bus.publish('xyz', message) 我们在python中有微服务,在.Net中有另一个,在这种情况下,python服务会发布一条消息,例如bus.publish('xyz', message)

And of course the .Net side has a type of xyz , we want to change the namespace of xyx to abc and still let the system to work without changing the python side. 当然,.Net方面的类型为xyz ,我们希望将xyx的命名空间更改为abc并且仍然允许系统正常工作而不更改python方面。

I've tried cfg.Message<ABC>(x => x.SetEntityName("xyz")); 我已经尝试过cfg.Message<ABC>(x => x.SetEntityName("xyz"));

But it does not work, i can see the message in the queue and that someone reads it but no consumer is triggered. 但这是行不通的,我可以在队列中看到该消息,并且有人读取了该消息,但没有触发任何消费者。

Thanks 谢谢

You need to look at the serialized message envelope (in JSON) to see how the message should be formatted (from Python, or any other language) and include the message types (using the type name formatting style required by MassTransit) in the envelope. 您需要查看序列化的消息信封(JSON),以了解如何格式化消息(使用Python或任何其他语言),并在信封中包括消息类型(使用MassTransit要求的类型名称格式样式)。

See this page in the documentation for details: http://masstransit-project.com/MassTransit/advanced/interoperability.html 有关详细信息,请参见文档中的此页面: http : //masstransit-project.com/MassTransit/advanced/interoperability.html

It isn't just the entity name, that's for publishing and subscribing, but you need to look at the actual types in the envelope to be able to deserialize the message by a consumer. 不仅是实体名称,而且还用于发布和订阅,但是您需要查看信封中的实际类型,以便消费者能够反序列化消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法修改 MassTransit 中的 MessageType? - Is there a way to modify the MessageType in MassTransit? Masstransit Sagas 和自定义活动的依赖注入问题 - Dependency Injection problem with Masstransit Sagas and Custom Activities 使用 Masstransit 订阅 RabbitMq 时无法覆盖交易所名称 - Unable to override exchange name while subscribing in RabbitMq using Masstransit 在公共交通中使用自定义 system.text.json 转换器 - using custom system.text.json convertor in masstransit 是否可以将动态数据添加到MassTransit快递/路由单自定义事件中? - Is it possible to add dynamic data to an MassTransit courier/routing slip custom event? MassTransit +使用定制类型消息的Azure服务总线 - MassTransit + azure service bus consuming custom type messages 用于请求/响应机制的 MassTransit 自定义查询/命令拓扑 - MassTransit custom Query/Command topology for Request/Response mechanism 如何在 Masstransit 中发布消息之前添加自定义标头 - How can I add custom headers before publishing message in Masstransit 如何使用Microsoft Bot Framework触发不同的MessageType - How to fire different MessageType with Microsoft Bot Framework 在没有先验messageType知识的情况下解析HL7 - Parsing an HL7 without a priori messageType knowledge
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM