Which layer should event listeners which listen to events from other bounded contexts be in?

119 views
Skip to first unread message

David

unread,
Nov 26, 2016, 8:34:51 PM11/26/16
to DDD/CQRS
Lets say I have 2 bounded contexts A and B. Bounded context A is interested in some events from bounded context B.

I can't decide whether the event listeners should be in the application or infrastructure layer. 

The application layer is where integration happens such as bounded context A doing a remote procedure call to bounded context B so this makes me want to put the listeners in the application layer.

The thing that makes me want to put the listeners in the infrastructure layer is that the events are arriving into the application through a message broker which is external to my application.

Any ideas?

Neil Hosey

unread,
Nov 27, 2016, 6:18:00 AM11/27/16
to DDD/CQRS
This is pretty much the anti corruption layer in DDD so I treat this as a standalone component, independent to my command and query services for thst bounded context. This way there is a clear separation of concern. You could argue this to be the third type of microservice inside a bounded context after command and query services. It also means you can provide access for the ACL to the query services if necessary

David

unread,
Nov 27, 2016, 10:01:12 AM11/27/16
to DDD/CQRS
So would you consider the ACL to be outside of the application layer? If so, wouldn't that mean it would be in the infrastructure layer? The new data comes in from the message queue, I translate the data if necessary and then talk to the application layer to execute a command.
Reply all
Reply to author
Forward
0 new messages