<p>I have been researching asynchronous messaging, and I like the way it elegantly deals with some problems within certain domains and how it makes domain concepts more explicit. But is it a viable pattern for general domain-driven development (at least in the service/application/controller layer), or is the design overhead such that it should be restricted to SOA-based scenarios, like remote services and distributed processing? </p>

[{'answer_id': 73944, 'author': 'James Strachan', 'author_id': 2068211, 'author_profile': 'https://Stackoverflow.com/users/2068211', 'pm_score': 4, 'selected': True, 'text': '<p>Great question :). The main problem with asynchronous messaging is that when folks use procedural or object oriented languages, working in an asynchronous or event based manner is often quite tricky and complex and hard for the programmer to read &amp; understand. Business logic is often way simpler if its built in a kinda synchronous manner - invoking methods and getting results immediately etc :).</p>\n\n<p>My rule of thumb is generally to try use simpler synchronous programming models at the micro level for business logic; then use asynchrony and SEDA at the macro level. </p>\n\n<p>For example submitting a purchase order might just write a message to a message queue; but the processing of the purchase order might require 10 different steps all being asynchronous and parallel in a high performance distributed system with many concurrent processes &amp; threads processing individual steps in parallel. So the macro level wiring is based on a SEDA kind of approach - but at the micro level the code for the individual 10 steps could be written mostly in a synchronous programming style.</p>\n'}, {'answer_id': 74065, 'author': 'BradS', 'author_id': 10537, 'author_profile': 'https://Stackoverflow.com/users/10537', 'pm_score': 2, 'selected': False, 'text': '<p>Like so many architecture and design questions, the answer is "it depends".</p>\n\n<p>In my experience, the strength of asynchronous messaging has been in the loose coupling it brings to a design. The coupling can be in:</p>\n\n<ul>\n<li>Time - Requests can be handled asynchronously, helping overall scalability.</li>\n<li>Space - As you point out, allowing for distributed processing in a more robust way than many synchronous designs.</li>\n<li>Technology - Messages and queues are one way to bridge technology differences.</li>\n</ul>\n\n<p>Remember that messages and queues are an abstraction that can have a variety of implementations. You don\'t necessarily need to use a JMS-compliant, transactional, high-performance messaging framework. Implemented correctly, a table in a relational database can act as a queue with the rows as messages. I\'ve seen both approaches used to great effect.</p>\n'}, {'answer_id': 75211, 'author': 'James Strachan', 'author_id': 2068211, 'author_profile': 'https://Stackoverflow.com/users/2068211', 'pm_score': 1, 'selected': False, 'text': '<p>I agree with @BradS too BTW</p>\n\n<p>BTW <a href="http://activemq.apache.org/camel/hiding-middleware.html" rel="nofollow noreferrer">here\'s a way of hiding the middleware from your business logic</a> while still getting the benefits of loose coupling &amp; SEDA - while being able to easily switch between a variety of different middleware technology - from in memory SEDA to JMS to AMQP to JavaSpaces to database, files or FTP etc</p>\n'}]
['https://Stackoverflow.com/questions/72895', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12356/']