{"id":2341,"date":"2011-12-12T09:34:53","date_gmt":"2011-12-12T08:34:53","guid":{"rendered":"http:\/\/www.devco.net\/?p=2341"},"modified":"2011-12-13T10:37:46","modified_gmt":"2011-12-13T09:37:46","slug":"common-messaging-patterns-using-stomp-part-3","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2011\/12\/12\/common-messaging-patterns-using-stomp-part-3.php","title":{"rendered":"Common Messaging Patterns Using Stomp – Part 3"},"content":{"rendered":"

Yesterday I showed a detailed example of a Asynchronous system using MOM<\/a>. Please read part 1<\/a> and part 2<\/a> of this series first before continuing below.<\/p>\n

The system shown yesterday was Asynchronous since there is no coupling, no conversation or time constraints. The Producer does not know or care what happens to the messages once Published or when that happens. This is a kind of nirvana for distributed systems but sadly it’s just not possible to solve every problem using this pattern.<\/p>\n

Today I’ll show how to use MOM technologies to solve a different kind of problem. Specifically I will show how large retailers scale their web properties using these technologies to create web sites that is more resilient to failure, easier to scale and easier to manage.<\/p>\n

Imagine you are just hitting buy<\/em> on some online retailers web page, perhaps they have implemented a 1-click based buying system where the very next page would be a Thank You page showing some details of your order and also recommendations of what other things you might like. It would have some personalized menus and in some cases even a personalized look and feel.<\/p>\n

By the time you see this page your purchase is not complete, it is still going on in the background but you have a fast acknowledge back and immediately you are being enticed to spend more money with relevant products. <\/p>\n

To achieve this in a PHP or Rails world you would typically have a page that runs top down and do things like generate your CSS page, generate your personalized menu then write some record into a database perhaps for a system like delayed job<\/a> to process the purchase later on and finally it would do a bunch of SQL queries to find the related items. <\/p>\n

This approach is very difficult to scale, all the hard work happens in your front controller, it has to be able to communicate with all the technology you choose in the backend and you end up with a huge monolithic chunk of code that can rapidly become a nightmare. If you need more capacity to render the recommendations you have no choice but to scale up the entire stack.<\/p>\n

The better approach is to decouple all of the bits needed to generate a web page, if you take the narrative above you would have small single purpose services that does the following:<\/p>\n