How to consume messages, of the same type, in different topics? #182
-
|
Lets say we hay the following topics:
And we are publishing the same message in the topics. (for example: MySampleMessage) How to consume the messages in these topics (2 subscribers with same message type) within the same application? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You have basically 3 options (possibly more):
I'd prefer the first choice, to avoid polluting my code and keep all transport-related configurations in a central place (the endpoint configurator). |
Beta Was this translation helpful? Give feedback.
You have basically 3 options (possibly more):
MySampleMessage, for exampleMySampleMessageFromDemo1andMySampleMessageFromDemo2. Then configure the inbound endpoints to deserialize those types instead of the baseMySampleMessage. The JSON is obviously compatible and you now have two different messages to subscribe to.IInboundEnvelope<MySampleMessage>and in the subscriber you can check the source topic (envelope.Endpoint.Name) and call two different methods (directly or via theIPublisher, wrapping the message inside another message model).IMessageFilterAttributeto decorate your subscribers and filter the messages…