eShopOnContainers icon indicating copy to clipboard operation
eShopOnContainers copied to clipboard

Question on SignalR and integration events

Open ludovicasa opened this issue 4 years ago • 0 comments

Hello,

I have a question regarding the usage of SignalR for notifications.

If I am not mistaken, in the current eShopOnContainers implementation only the Ordering domain is sending notifications to the clients. There is a dedicated Ordering.SignalrHub micro-service that subscribes to integration events sent by the Ordering.API and then call the UpdatedOrderState function on client side via SignalR.

It means that if now I want to the Ordering domain to also send a notification for OrderStartedIntegrationEvent, I would have to subscribe to this event (and recopy the OrderStartedIntegrationEvent class) in the Ordering.SignalrHub project and declare a new function/subscription in the client (SignalrService.ts) for that new notification. This should be done each time a new notification needs to be added.

What if instead, we have a unique NotifcationIntegrationEvent sent by all domain micro-services. This event could define common properties (EventType, Caller, Domain, EventDateTime, etc.) and a Data property that could be filled with information specific to the event type. The SignalR micro-service would have to subscribe to only this event. And we could have only one SignalR micro-service instead of one per domain. On client side, only one function (Notify for example) should be needed with some routing logic depending on the EventType property.

Adding a new notification would mean to just send the NotifcationIntegrationEvent from the domain service and update the client to handle this new EventType.

What are you thoughts about this approach? Do you think it would remove some flexibility on the notification mechanism?

Thanks.

ludovicasa avatar Jan 02 '22 21:01 ludovicasa