{"action":"created","comment":{"url":"https://api.github.com/repos/codurance/site/pulls/comments/61566395","id":61566395,"diff_hunk":"@@ -0,0 +1,46 @@\n+---\n+layout: post\n+name: Async-systems-with-sync-clients\n+title: 'Async systems with sync clients'\n+date: 2016-04-28 00:20:00 +00:00\n+author: Felipe Fernández\n+image:\n+    src: /assets/img/custom/blog/time.png\n+    attribution:\n+      text: Water time by barrasa8\n+      href: https://www.flickr.com/photos/barrasa8/2492558453\n+tags:\n+- distributed systems\n+- akka\n+- integration\n+- architecture\n+\n+---\n+\n+As [Reactive Manifesto](http://www.reactivemanifesto.org/) says Reactive systems are: Responsive, Resilient, Elastic and Message Driven. The last principle often goes together with non-blocking async protocols. This style of communication \"allows recipients to only consume resources while active, leading to less system overhead\". This fits perfectly with new demands of efficiency derived from the elastic model of cloud providers. However not every system is async and integrating an async system with a sync client could be tricky.\n+\n+\n+## Integration Strategies\n+\n+We can fix the mismatch of communication styles through a couple of strategies.\n+\n+### Polling\n+\n+This involves work for both parties. First round trip of this protocol involves client sending some request to the server with an outcome of ACK/NACK. This is called fire and forget. Assuming HTTP, the server will return status code 202 (Accepted). The async process will eventually succeed or fail and that result will be exposed by the server in a different endpoint. Client will have to poll periodically that endpoint to figure out the status of the operation.\n+\n+Polling is by nature inefficient but could be a good solution when the technological stack doesn't allow bidirectional protocols like Web Sockets.\n+\n+### Hiding asynchronicity\n+\n+If we don't have control over those clients, we'll probably have to hide our async nature under some sync layer. That layer will implement a polling or pub/sub mechanism bounded by a timeout.\n+\n+## Learning by example\n+\n+In this series of posts we'll implement last strategy with a pub/sub mechanism. We'll add some essential complexities to our domain to make more juicy the exercise.","path":"_posts/2016-04-28-async-systems-with-sync-clients.md","position":39,"original_position":39,"commit_id":"97adf4f734eb0541fa4e5e53cd4abe47e16db2f7","original_commit_id":"97adf4f734eb0541fa4e5e53cd4abe47e16db2f7","user":{"login":"roberttaylor426","id":535032,"avatar_url":"https://avatars.githubusercontent.com/u/535032?v=3","gravatar_id":"","url":"https://api.github.com/users/roberttaylor426","html_url":"https://github.com/roberttaylor426","followers_url":"https://api.github.com/users/roberttaylor426/followers","following_url":"https://api.github.com/users/roberttaylor426/following{/other_user}","gists_url":"https://api.github.com/users/roberttaylor426/gists{/gist_id}","starred_url":"https://api.github.com/users/roberttaylor426/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roberttaylor426/subscriptions","organizations_url":"https://api.github.com/users/roberttaylor426/orgs","repos_url":"https://api.github.com/users/roberttaylor426/repos","events_url":"https://api.github.com/users/roberttaylor426/events{/privacy}","received_events_url":"https://api.github.com/users/roberttaylor426/received_events","type":"User","site_admin":false},"body":"...to make the exercise more juicy.","created_at":"2016-04-29T12:01:58Z","updated_at":"2016-04-29T12:01:58Z","html_url":"https://github.com/codurance/site/pull/159#discussion_r61566395","pull_request_url":"https://api.github.com/repos/codurance/site/pulls/159","_links":{"self":{"href":"https://api.github.com/repos/codurance/site/pulls/comments/61566395"},"html":{"href":"https://github.com/codurance/site/pull/159#discussion_r61566395"},"pull_request":{"href":"https://api.github.com/repos/codurance/site/pulls/159"}}},"pull_request":{"url":"https://api.github.com/repos/codurance/site/pulls/159","id":68346769,"html_url":"https://github.com/codurance/site/pull/159","diff_url":"https://github.com/codurance/site/pull/159.diff","patch_url":"https://github.com/codurance/site/pull/159.patch","issue_url":"https://api.github.com/repos/codurance/site/issues/159","number":159,"state":"open","locked":false,"title":"Async systems with sync clients.","user":{"login":"felipefzdz","id":369379,"avatar_url":"https://avatars.githubusercontent.com/u/369379?v=3","gravatar_id":"","url":"https://api.github.com/users/felipefzdz","html_url":"https://github.com/felipefzdz","followers_url":"https://api.github.com/users/felipefzdz/followers","following_url":"https://api.github.com/users/felipefzdz/following{/other_user}","gists_url":"https://api.github.com/users/felipefzdz/gists{/gist_id}","starred_url":"https://api.github.com/users/felipefzdz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felipefzdz/subscriptions","organizations_url":"https://api.github.com/users/felipefzdz/orgs","repos_url":"https://api.github.com/users/felipefzdz/repos","events_url":"https://api.github.com/users/felipefzdz/events{/privacy}","received_events_url":"https://api.github.com/users/felipefzdz/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-29T09:44:14Z","updated_at":"2016-04-29T12:01:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10cd29d87e1f349d43769c8d7c959407e1081bc3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codurance/site/pulls/159/commits","review_comments_url":"https://api.github.com/repos/codurance/site/pulls/159/comments","review_comment_url":"https://api.github.com/repos/codurance/site/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codurance/site/issues/159/comments","statuses_url":"https://api.github.com/repos/codurance/site/statuses/97adf4f734eb0541fa4e5e53cd4abe47e16db2f7","head":{"label":"codurance:async","ref":"async","sha":"97adf4f734eb0541fa4e5e53cd4abe47e16db2f7","user":{"login":"codurance","id":5751452,"avatar_url":"https://avatars.githubusercontent.com/u/5751452?v=3","gravatar_id":"","url":"https://api.github.com/users/codurance","html_url":"https://github.com/codurance","followers_url":"https://api.github.com/users/codurance/followers","following_url":"https://api.github.com/users/codurance/following{/other_user}","gists_url":"https://api.github.com/users/codurance/gists{/gist_id}","starred_url":"https://api.github.com/users/codurance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codurance/subscriptions","organizations_url":"https://api.github.com/users/codurance/orgs","repos_url":"https://api.github.com/users/codurance/repos","events_url":"https://api.github.com/users/codurance/events{/privacy}","received_events_url":"https://api.github.com/users/codurance/received_events","type":"Organization","site_admin":false},"repo":{"id":38424930,"name":"site","full_name":"codurance/site","owner":{"login":"codurance","id":5751452,"avatar_url":"https://avatars.githubusercontent.com/u/5751452?v=3","gravatar_id":"","url":"https://api.github.com/users/codurance","html_url":"https://github.com/codurance","followers_url":"https://api.github.com/users/codurance/followers","following_url":"https://api.github.com/users/codurance/following{/other_user}","gists_url":"https://api.github.com/users/codurance/gists{/gist_id}","starred_url":"https://api.github.com/users/codurance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codurance/subscriptions","organizations_url":"https://api.github.com/users/codurance/orgs","repos_url":"https://api.github.com/users/codurance/repos","events_url":"https://api.github.com/users/codurance/events{/privacy}","received_events_url":"https://api.github.com/users/codurance/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codurance/site","description":"","fork":false,"url":"https://api.github.com/repos/codurance/site","forks_url":"https://api.github.com/repos/codurance/site/forks","keys_url":"https://api.github.com/repos/codurance/site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codurance/site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codurance/site/teams","hooks_url":"https://api.github.com/repos/codurance/site/hooks","issue_events_url":"https://api.github.com/repos/codurance/site/issues/events{/number}","events_url":"https://api.github.com/repos/codurance/site/events","assignees_url":"https://api.github.com/repos/codurance/site/assignees{/user}","branches_url":"https://api.github.com/repos/codurance/site/branches{/branch}","tags_url":"https://api.github.com/repos/codurance/site/tags","blobs_url":"https://api.github.com/repos/codurance/site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codurance/site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codurance/site/git/refs{/sha}","trees_url":"https://api.github.com/repos/codurance/site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codurance/site/statuses/{sha}","languages_url":"https://api.github.com/repos/codurance/site/languages","stargazers_url":"https://api.github.com/repos/codurance/site/stargazers","contributors_url":"https://api.github.com/repos/codurance/site/contributors","subscribers_url":"https://api.github.com/repos/codurance/site/subscribers","subscription_url":"https://api.github.com/repos/codurance/site/subscription","commits_url":"https://api.github.com/repos/codurance/site/commits{/sha}","git_commits_url":"https://api.github.com/repos/codurance/site/git/commits{/sha}","comments_url":"https://api.github.com/repos/codurance/site/comments{/number}","issue_comment_url":"https://api.github.com/repos/codurance/site/issues/comments{/number}","contents_url":"https://api.github.com/repos/codurance/site/contents/{+path}","compare_url":"https://api.github.com/repos/codurance/site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codurance/site/merges","archive_url":"https://api.github.com/repos/codurance/site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codurance/site/downloads","issues_url":"https://api.github.com/repos/codurance/site/issues{/number}","pulls_url":"https://api.github.com/repos/codurance/site/pulls{/number}","milestones_url":"https://api.github.com/repos/codurance/site/milestones{/number}","notifications_url":"https://api.github.com/repos/codurance/site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codurance/site/labels{/name}","releases_url":"https://api.github.com/repos/codurance/site/releases{/id}","deployments_url":"https://api.github.com/repos/codurance/site/deployments","created_at":"2015-07-02T09:54:02Z","updated_at":"2016-03-14T09:39:20Z","pushed_at":"2016-04-29T09:44:15Z","git_url":"git://github.com/codurance/site.git","ssh_url":"git@github.com:codurance/site.git","clone_url":"https://github.com/codurance/site.git","svn_url":"https://github.com/codurance/site","homepage":null,"size":158380,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"codurance:master","ref":"master","sha":"2b1ef0c61ea38c151bbb026f878bce146d4d4bb9","user":{"login":"codurance","id":5751452,"avatar_url":"https://avatars.githubusercontent.com/u/5751452?v=3","gravatar_id":"","url":"https://api.github.com/users/codurance","html_url":"https://github.com/codurance","followers_url":"https://api.github.com/users/codurance/followers","following_url":"https://api.github.com/users/codurance/following{/other_user}","gists_url":"https://api.github.com/users/codurance/gists{/gist_id}","starred_url":"https://api.github.com/users/codurance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codurance/subscriptions","organizations_url":"https://api.github.com/users/codurance/orgs","repos_url":"https://api.github.com/users/codurance/repos","events_url":"https://api.github.com/users/codurance/events{/privacy}","received_events_url":"https://api.github.com/users/codurance/received_events","type":"Organization","site_admin":false},"repo":{"id":38424930,"name":"site","full_name":"codurance/site","owner":{"login":"codurance","id":5751452,"avatar_url":"https://avatars.githubusercontent.com/u/5751452?v=3","gravatar_id":"","url":"https://api.github.com/users/codurance","html_url":"https://github.com/codurance","followers_url":"https://api.github.com/users/codurance/followers","following_url":"https://api.github.com/users/codurance/following{/other_user}","gists_url":"https://api.github.com/users/codurance/gists{/gist_id}","starred_url":"https://api.github.com/users/codurance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codurance/subscriptions","organizations_url":"https://api.github.com/users/codurance/orgs","repos_url":"https://api.github.com/users/codurance/repos","events_url":"https://api.github.com/users/codurance/events{/privacy}","received_events_url":"https://api.github.com/users/codurance/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codurance/site","description":"","fork":false,"url":"https://api.github.com/repos/codurance/site","forks_url":"https://api.github.com/repos/codurance/site/forks","keys_url":"https://api.github.com/repos/codurance/site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codurance/site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codurance/site/teams","hooks_url":"https://api.github.com/repos/codurance/site/hooks","issue_events_url":"https://api.github.com/repos/codurance/site/issues/events{/number}","events_url":"https://api.github.com/repos/codurance/site/events","assignees_url":"https://api.github.com/repos/codurance/site/assignees{/user}","branches_url":"https://api.github.com/repos/codurance/site/branches{/branch}","tags_url":"https://api.github.com/repos/codurance/site/tags","blobs_url":"https://api.github.com/repos/codurance/site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codurance/site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codurance/site/git/refs{/sha}","trees_url":"https://api.github.com/repos/codurance/site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codurance/site/statuses/{sha}","languages_url":"https://api.github.com/repos/codurance/site/languages","stargazers_url":"https://api.github.com/repos/codurance/site/stargazers","contributors_url":"https://api.github.com/repos/codurance/site/contributors","subscribers_url":"https://api.github.com/repos/codurance/site/subscribers","subscription_url":"https://api.github.com/repos/codurance/site/subscription","commits_url":"https://api.github.com/repos/codurance/site/commits{/sha}","git_commits_url":"https://api.github.com/repos/codurance/site/git/commits{/sha}","comments_url":"https://api.github.com/repos/codurance/site/comments{/number}","issue_comment_url":"https://api.github.com/repos/codurance/site/issues/comments{/number}","contents_url":"https://api.github.com/repos/codurance/site/contents/{+path}","compare_url":"https://api.github.com/repos/codurance/site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codurance/site/merges","archive_url":"https://api.github.com/repos/codurance/site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codurance/site/downloads","issues_url":"https://api.github.com/repos/codurance/site/issues{/number}","pulls_url":"https://api.github.com/repos/codurance/site/pulls{/number}","milestones_url":"https://api.github.com/repos/codurance/site/milestones{/number}","notifications_url":"https://api.github.com/repos/codurance/site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codurance/site/labels{/name}","releases_url":"https://api.github.com/repos/codurance/site/releases{/id}","deployments_url":"https://api.github.com/repos/codurance/site/deployments","created_at":"2015-07-02T09:54:02Z","updated_at":"2016-03-14T09:39:20Z","pushed_at":"2016-04-29T09:44:15Z","git_url":"git://github.com/codurance/site.git","ssh_url":"git@github.com:codurance/site.git","clone_url":"https://github.com/codurance/site.git","svn_url":"https://github.com/codurance/site","homepage":null,"size":158380,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codurance/site/pulls/159"},"html":{"href":"https://github.com/codurance/site/pull/159"},"issue":{"href":"https://api.github.com/repos/codurance/site/issues/159"},"comments":{"href":"https://api.github.com/repos/codurance/site/issues/159/comments"},"review_comments":{"href":"https://api.github.com/repos/codurance/site/pulls/159/comments"},"review_comment":{"href":"https://api.github.com/repos/codurance/site/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codurance/site/pulls/159/commits"},"statuses":{"href":"https://api.github.com/repos/codurance/site/statuses/97adf4f734eb0541fa4e5e53cd4abe47e16db2f7"}}}}