Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does a task queue fit in Clean Architecture?

According to uncle Bob's Clean Architecture, enterprise and application business rules (which conceptually are comprised of commands) are located in layers below the outer interface layers. Thus interfaces are free to run business rules whenever they are called. However, in some circumstances it's also necessary to run business rules in background processes, either individually or as part of workflows, either triggered by input from external interfaces or by job schedulers. In that case, where does a task queue service fit in the Clean Architecture?

like image 871
RAM Avatar asked Aug 10 '26 06:08

RAM


1 Answers

The task queue is a detail like the UI or the web. Just another I/O mechanism.

For the use case it doesn't matter if it gets its input from a

  • user interaction
  • scheduler thread
  • unit test

That I/O independece makes use cases easy to test.

like image 167
René Link Avatar answered Aug 13 '26 10:08

René Link