Receiving Messages in the Shopping Baskets Module
Understand how to receive the messages in the Shopping Baskets module.
To receive event messages, the initial composition root changes are very much the same, as outlined here:
We need to register the
storespb
events with our registry.We need to create an event stream instance.
Adding store integration event handlers
On the receiving side, we will always be using event handlers. The EventHandler
instance we need to create is just like the domain and aggregate event handlers we have been working with from the past couple of chapters.
For now, we will log a debug message when we receive an event so that we can verify that we are really communicating with events. On this end, when we get a StoreCreated
event, the event defined in the storespb
package, it will have been serialized, sent over, and deserialized back into our event. The code is illustrated in the following snippet:
Get hands-on with 1400+ tech skills courses.