john
john

Reputation: 35

How to implement RabbitMQ consumer in DDD?

I am implementing a system by DDD, I have 3 layer (application | Infrastructure | domain)

I have two type connections between microservices sync and async

in sync connection I create an api in application layer but I dont know Which layer is appropriate to implement a consumer for RabbitMQ

Where should I write the consumer?

Upvotes: 2

Views: 1127

Answers (1)

GeertPt
GeertPt

Reputation: 17874

You create an application service and the application event matching the RabbitMQ message in the application layer. The application service might do some context mapping and send the event to the domain layer where it's handled according to the domain's internal logic.

Depending on which framework you use, you might need an adapter to link your application service to RabbitMQ, and maybe a message convertor too. If that's the case, you put that adapter in the infrastructure layer.

Upvotes: 3

Related Questions