Derived types are not published to consumers in MassTransit

☆樱花仙子☆ 提交于 2019-12-06 14:32:31
Travis

Eugene's comment is correct. What's happening here is you are publishing a message of type ContentItemMessage. A consumer of HtmlBlockNewMessage will not executed since the message is published as a ContentItemMessage and a ServiceBusMessage. MassTransit message mis-typing is one of a number of things out there on how this works.

Your options:

  1. Change AddContentItem to use a generic, perhaps with a constraint
  2. Used reflection to invoke Publish with the right type information
  3. Restructure how you publish things so this isn't an issue any more

The bottom line is you should always publish as the type you want received. Polymorphism in messaging is tricky.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!