Making the Store Management module asynchronous
We are going to update the Store Management module to publish integration events and will also update the Shopping Baskets module to receive messages. The Shopping Baskets module will not be doing much more than logging the receipt of the message. Using the data will come in handy in the next chapter when we learn about event-carried state transfer.
Modifying the monolith configuration
Starting with a simple configuration for NATS, we need a Uniform Resource Locator (URL) to connect to and a name for our stream. Of course, both could be hardcoded or put into variables in the code, but I run the application from a Docker container and without. The stream name is used in a few places, so having it be part of the configuration for the application is the lazy option. The code is illustrated here:
NatsConfig struct {
URL string `required:"true"`
Stream...