zarusz/SlimMessageBus

[Host.Hybrid] Support to publish event to more than one child bus if event type match

baoduy opened this issue ยท 9 comments

Hi @zarusz
We should have a chat room for this repo for some questioning.

I have a question I need your help to clarify.

Let's say I have two children bus (Bus1 and Bus2). When pushing a message, how could I select which bus to push?

Thanks
Steven

Hello @baoduy , there is a gitter chat link available on the main repo page, it's meant for just that.

To answer your question, during publish the hybrid bus matches the child bus based on the message type being published. Let say that Bus1 declares message A and Bus2 declares message B, then when you publish A it will be routed to Bus1.
It's described in the hybrid bus docs.

Unless you need something more than that?

Hi @zarusz
Thank you so much for your response. Just a quick clarification. If I define the same message type on both provide, will it be sent to both Service Buses?

By the way, Merry Christmas and Happy New Year.

Thanks
Steven

I only envisioned declaring distinct message types for each child bus. So currently it won't work like that. If needed we could extend it to do so. Could you elaborate on your use case please?

What types of buses you have?
Would you want it to send to both child buses at the same time?

Merry Christmas and Happy New Year ;)

Hi @zarusz

I am currently working on an application that uses the DDD design. By default, we push all events to an internal provider called the Memory Provider.

However, for certain events that require external services, we need to send them to an external provider called the Azure Service Bus. The issue is that our library does not support this scenario, so we have to convert the internal events to external events at the handler level, which is not ideal.

It would be helpful if the library supported this scenario so that the internal handlers could be cleaner and not have to forward the messages to the external bus.

@baoduy that is a good scenario - thanks for the explanation. I've also encountered a similar need on another project. Over there we use the memory handler (for domain events) and decided to translate these in-memory domain events to external events (via a translating handler) - this is to decouple the internal event from the external event schema and allow them to evolve independently.

That said, it's also a fair ask to add the feature to allow the hybrid bus to dispatch the event to all child buses that declare such an event type. I will go ahead and change the description of this issue and add it to my immediate backlog (super simple change).

Hi @zarusz
I just did some basic checks, and it is a working property. I will continue to do some more testing on this and will let you know if there are any.

Thank you so much for your quick action.
Steven

Thanks! I merged the PR and will keep this issue open for a few days just in case. This feature will be released within few weeks with another feature I am working on. Cheers

thank you so much for your help. @zarusz. Let me close the issue here also.