1

I'm starting to use Mass Transit and I have one question. I'm using clean architecture with a mediator pattern. My project's structure is as follows:

  • Domain
  • Infrastructure
  • Application
  • WebApi

I would like to add Mass Transit, so I've added the following projects:

  • SharedContracts
  • Messaging

My question is: should I write the logic in the consumers, or should I put it in the application's handlers? What is your opinion on this?

Thank you.

1 Answer 1

3

The easiest and most direct answer is "Treat consumers like you treat your controllers/handlers." So, if you don't put business logic in your controllers, don't put it in your consumers. If you do, put that logic in your controllers, then it would make sense to also put it in your consumers.

In general, I find this advice will fit with any interpretation of clean architecture.

2
  • I feel it same. So your advice is have logic in application layer and in consumers only call handler over meditor same like in controller. right?
    – pietro
    Commented Mar 16, 2023 at 12:45
  • However you treat your controllers, treat the consumers the same. If you do controller to mediator, then do consumer to mediator.
    – drusellers
    Commented Mar 16, 2023 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.