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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
However you treat your controllers, treat the consumers the same. If you do controller to mediator, then do consumer to mediator.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.