Skip to content

How to consume messages, of the same type, in different topics? #182

Answered by BEagle1984
gabriel-sk-dev asked this question in Q&A
Discussion options

You must be logged in to vote

You have basically 3 options (possibly more):

  1. Create two message models that inherit from MySampleMessage, for example MySampleMessageFromDemo1 and MySampleMessageFromDemo2. Then configure the inbound endpoints to deserialize those types instead of the base MySampleMessage. The JSON is obviously compatible and you now have two different messages to subscribe to.
  2. Subscribe once to IInboundEnvelope<MySampleMessage> and in the subscriber you can check the source topic (envelope.Endpoint.Name) and call two different methods (directly or via the IPublisher, wrapping the message inside another message model).
  3. Build an IMessageFilterAttribute to decorate your subscribers and filter the messages…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gabriel-sk-dev
Comment options

Answer selected by gabriel-sk-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants