<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">I am implementing an abstraction over dynamic pub/sub. The idea is that you have named "themes", and within those themes you have "subjects" that can be used as a filter. Themes may or may not be transient.</span><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">I think have two choices:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
1) Each named "theme" is a separate topic exchange and "subjects" map directly to routing keys <i>(i.e., "stocks" topic exchange, with messages having routing keys like "nasdaq.apple.price")</i>.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">2) There is a single topic exchange and the routing key is a composite of theme and subject <i>(i.e., "themes" topic exchange, with messages having routing keys like "theme.stocks.subject.nasdaq.apple.price")</i>.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Although #1 has a better one-to-one mapping to my problem, I am inclined to go with #2 because it is much easier to manage (a single exchange that never gets deleted, vs many exchanges that I must manage the lifecycle of).</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">The only thing I am unsure of is if there is any difference in performance? Multiple exchanges are more expensive in memory, but will a single exchange need more CPU to route messages because it is dealing with so many more disparate bindings?</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Thanks for any guidance.</div></div>