[英]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.