Patterns for creating an Event Bus

Hello, we’re using EventStore’s routing capabilities as an event bus in our C# project and looking for a little guidance.
We’re using NServiceBus as our command bus, so we wanted to follow a very similar approach for our event bus so there was some semblance of consistency.

I looked at what Szymon did in his NServiceBus approach and made something somewhat similar.

What I’m doing:

When we publish events from an aggregate, they are all categorized as"Events-".

I set up a category projection for “Events-” which reorients the events by event type(s).

One event can represent more than one event type since we are emulating NSB’s topic per implemented/inherited interface.

So I’m creating a topic per message interface and putting that in the metadata in a Topics array.

In the Events category projection, I’m then projecting events into one or more EventSink projections using linkTo. So the projection looks like:

.when({$any : function(s,e) {
if(e.metadata.topics){ for (var i = 0; i < e.metadata.topics.length; i++){linkTo(‘EventSink-’ + e.metadata.topics[i], e);}}


Pretty straightforward. In this case I’m using “linkTo” since I’m basically reorienting the events into different views.

From the subscriber perspective, a subscriber can listen to one or more event types. In this case I’m basically setting up a virtual Queue for my subscriber to listen to with all of the events that they care about.

So when a subscriber comes online, it sets up a projection specific to the events it cares about. For example:

fromStreams(‘EventSink-SomethingStarted’, ‘EventSink-SomethingDidSomethingElse’).when({$any : function(s,e) { copyTo(‘Queue-For_Specific_Listener_That_Wants_These’, e); }});


In this case it seems appropriate to use “copyTo” since I’m creating a queue stream for a specific subscriber that I want to have autonomy from the originally emitted event. Perhaps at some point the original aggregate events are purged/archived/whatever…

FYI, our load will be very low for some time: <10k events per hour I believe.


  • Does this approach with using linkTo/copyTo make sense?
  • Is there a different pattern that is recommended for something like this?
  • Would copy vs link have any impact on event ordering in the resultant stream?
  • Would you have any reservations about the “Events” category projection above since it examines topics in each message to determine the correct linkto projection?
  • Would it be more performant to create a separate static “.when” per message type when building out the query?



Why use copy to instead of link to?

linkto is just an optimized copy to unless you are deleting the original event.