{"id":1576,"date":"2014-08-21T09:22:31","date_gmt":"2014-08-21T15:22:31","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=1576"},"modified":"2014-08-19T09:23:07","modified_gmt":"2014-08-19T15:23:07","slug":"building-a-system-with-ironmq-and-python","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/1576","title":{"rendered":"Building a System with IronMQ and Python"},"content":{"rendered":"<figure style=\"width: 240px\" class=\"wp-caption alignleft\"><img loading=\"lazy\" decoding=\"async\" title=\"Message (85\/365) by andrewrennie\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2014\/08\/4472877398_148bb93a35_m_messages.jpg\" alt=\"messages photo\" width=\"240\" height=\"160\" \/><figcaption class=\"wp-caption-text\"><small>Photo by <a href=\"http:\/\/www.flickr.com\/photos\/29712408@N02\/4472877398\" target=\"_blank\">andrewrennie<\/a> <a title=\"Attribution-ShareAlike License\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/2.0\/\" target=\"_blank\" rel=\"nofollow\"><img decoding=\"async\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/plugins\/wp-inject\/images\/cc.png\" alt=\"\" \/><\/a><\/small><\/figcaption><\/figure>\n<p>One of my most recent projects was writing a system to deliver real estate listing data to a content management system. The CMS was not in my control. Since the listing data source was bursty and I wasn&#8217;t sure how the CMS would handle the load, I decided to use a message queue, where the messages would have a JSON payload. Message queues are great at decoupling components of a system.<\/p>\n<p>For the queue, I used <a href=\"http:\/\/www.iron.io\/mq\">IronMQ<\/a>. The company already was using it, it has a <a href=\"http:\/\/www.iron.io\/pricing\">free tier<\/a> (up to 24 messages a second), the service has been stable and reliable, it has <a href=\"http:\/\/dev.iron.io\/mq\/libraries\/\">great language SDKs<\/a>, and setting up a durable message queue is something I&#8217;d rather outsource. (I do wish Zapier supported it.) In other situations (when posting messages from mobile apps), we ran <a href=\"https:\/\/www.varnish-cache.org\/\">Varnish<\/a> in front of IronMQ so that it could be replaced easily. In this case, we didn&#8217;t because there were fewer moving pieces (it was server to server communication and it would be easier to swap out IronMQ should that be required).<\/p>\n<p>I wrote the bridge code from the listing database to the message queue in python. The shop was mostly Java and some python, and python seemed a better fit for a small &#8216;pull from here, push to there&#8217; application. I used <a href=\"http:\/\/pytest.org\/latest\/\">pytest<\/a> for unit testing, jenkins to run the unit tests in a CI environment, and <a href=\"https:\/\/pypi.python.org\/pypi\/autopep8\/\">autopep8<\/a> for formatting. My colleague was a more experienced python programmer, so I was able to lean on him for questions. I didn&#8217;t find python hard to pick back up (I&#8217;d scripted in python a little years ago), and it was a fun language to code in. Reminded me of perl w\/r\/t packages and quick developer feedback. I did miss Java&#8217;s dependency management, though (my college recommended <a href=\"http:\/\/virtualenv.readthedocs.org\/en\/latest\/\">virtualenv<\/a> as a possible solution).<\/p>\n<p>The JSON payload would allow developers writing the message consumer to use almost any language they wanted&#8211;any language if they used the IronMQ <a href=\"http:\/\/dev.iron.io\/mq\/reference\/api\/\">REST API<\/a> rather than an SDK.<\/p>\n<p>I can&#8217;t share the code, but for this kind of problem, python was a great solution. And I&#8217;ll reach for IronMQ any time I need a message queue. This pair of technologies was quick to implement, easy to deploy, and high performance wasn&#8217;t really a requirement, since the frequency of the listing delivery was the real bottleneck.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of my most recent projects was writing a system to deliver real estate listing data to a content management system. The CMS was not in my control. Since the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62,10,33],"tags":[],"class_list":["post-1576","post","type-post","status-publish","format-standard","hentry","category-apis","category-dynamic-languages","category-useful-tools"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1576"}],"version-history":[{"count":3,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1576\/revisions"}],"predecessor-version":[{"id":1580,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1576\/revisions\/1580"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}