Setting up a RabbitMQ instance and publishing an event

Event bus communication is composed of two parts: the sender and the receiver. In the case of an event, the actors' names are publishers and subscribers. The previous section described the implementation of the subscriber part. In this case, the catalog service will be the publisher and the cart service will be the subscriber. Before we look at how to implement the publisher part, we need to create a RabbitMQ instance using a Docker container by adding a docker-compose.yml file to the catalog service:

version: "3.7"services:    ...          catalog_esb:    container_name: catalog_esb    image: rabbitmq:3-management-alpine    ports:      - 5672:5672      - 15672:15672    networks:      - my_network    ...networks:    my_network ...

Get Hands-On RESTful Web Services with ASP.NET Core 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.