{"id":2016,"date":"2011-10-10T22:26:56","date_gmt":"2011-10-10T21:26:56","guid":{"rendered":"http:\/\/www.gamlor.info\/wordpress\/?p=2016"},"modified":"2021-03-11T09:14:43","modified_gmt":"2021-03-11T08:14:43","slug":"akka-mobile-the-idea","status":"publish","type":"post","link":"https:\/\/www.gamlor.info\/wordpress\/2011\/10\/akka-mobile-the-idea\/","title":{"rendered":"Akka-Mobile: The Idea"},"content":{"rendered":"<p>What is Akka-Mobile? Right now it\u2019s an idea. It\u2019s my semester term project at the University of Applied Science in Rapperswil. In this blog post I give a short overview of the idea.<\/p>\n<h2>What is Akka?<\/h2>\n<p><a href=\"http:\/\/akka.io\">Akka<\/a> is a framework for Scala (and also Java) to bring Erlang style actors (and tons of other things) to the JVM. In the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Actor_model\">actor model<\/a> we have actors which communicate through message passing with each other. Each actor can react to messages, do some computation and sent messages to other actors which he knows. The message passing it the only way actors can communicate, there not shared state or other communication channels.<\/p>\n<h2>Why Actors?<\/h2>\n<p>I just cite from the Akka website:<\/p>\n<blockquote><p>\u201cWe believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it&#8217;s because we are using the wrong tools and the wrong level of abstraction.\u00a0 Akka is here to change that.\u00a0 Using the Actor Model together with Software Transactional Memory we raise the abstraction level and provide a better platform to build correct concurrent and scalable applications.\u201d<\/p><\/blockquote>\n<p>And:<\/p>\n<blockquote><p>\u201cFor fault-tolerance we adopt the &#8220;Let it crash&#8221; \/ &#8220;Embrace failure&#8221; model which have been used with great success in the telecom industry to build applications that self-heal, systems that never stop.\u201d<\/p><\/blockquote>\n<h2>Akka Mobile?<\/h2>\n<p>The Actor Model works well for distributed, \u2018event\u2019-oriented and fault tolerant environments. Where do we have such systems? Yes, in the mobile space! Think about all the phones our there running tons of applications. Many of these applications communicate with a central service or even between devices. Think about all the applications on your phone which have \u2018real-time\u2019 communication features? Chat apps, social apps like Facebook &amp; Twitter, GPS apps which incorporates the latest traffic information etc. And all these applications have to deal with network faults, message delivery and coordination.<\/p>\n<p>So I think the Actor model is a good fit for these kinds of \u2018real time\u2019 applications on the phone. That\u2019s why I want to get the Actor goodness on the phone.<\/p>\n<div id=\"attachment_2018\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/10\/actors-phones.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2018\" class=\"size-medium wp-image-2018\" title=\"actors-phones\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/10\/actors-phones-300x137.png\" alt=\"Actors and Phones Don't Get Along (Yet)\" width=\"300\" height=\"137\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/10\/actors-phones-300x137.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/10\/actors-phones.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2018\" class=\"wp-caption-text\">Actors and Phones Don&#39;t Get Along (Yet)<\/p><\/div>\n<h2>30\u2019000 Feet Overview<\/h2>\n<p>Ok, the basic idea is very simple. We simply bring the actors to the phone. These actors can communication locally or with a remote service. On the phone we can send messages to some actors running on the Server. On the server we can access each phone like an actor and send messages to it.<\/p>\n<p>For example on the phone we simply can send a message to the server like this:<\/p>\n<p>theServiceOnTheServer ! \u201cHi\u201d<\/p>\n<p>And on the server we can react to this and reply:<\/p>\n<p>onMessage \u201cHi\u201d =&gt;\u00a0 reply(\u201cHi there\u201d)<\/p>\n<p>These messages are then delivered to each mailbox of the actors running on the server and phone. There the actors then can read and reacht to these messages. The framework handles the communication, failures, etc. of the messages. Of course it won\u2019t be a silver bullet and you still need to deal with errors. However with an Actor model dealing with errors is easier than with more traditional models (like exceptions).<\/p>\n<div id=\"attachment_2019\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/10\/actor-communication.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2019\" class=\"size-medium wp-image-2019\" title=\"actor-communication\" src=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/10\/actor-communication-300x134.png\" alt=\"Actor Communication\" width=\"300\" height=\"134\" srcset=\"https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/10\/actor-communication-300x134.png 300w, https:\/\/www.gamlor.info\/wordpress\/wp-content\/uploads\/2011\/10\/actor-communication.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-2019\" class=\"wp-caption-text\">Actor Communication<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2>Tons of Details<\/h2>\n<p>While the actor model provides are very simple model, there are tons of details which need to go into the implementation. How do deal with connection losses and offline devices? How are communication errors exposed to the actors? And of course additions for the mobile space should also be considered. For example messages which are only delivered when the device is actively used and other messages which are always delivered.<\/p>\n<h2>Back To Akka<\/h2>\n<p>Now of course I could go with a green field approach and implement everything from scratch, but that would be a lot of wasted effort. Akka already has solid implemented Actors including remote communications. However Akka is intended for servers and clusters. The current remote implementation isn\u2019t really intended to be used on mobile devices. So my goal it the change that and bring parts of the Akka goodness to the mobile space.<\/p>\n<h2>Conclusion &amp; Next Time<\/h2>\n<p>Ok, I want bring Akka actors to the mobile space. The motivation for this is that the actor model is a good fit for complex distributed computing, like in the mobile space.<\/p>\n<p>Anyway, I will go into more details in future posts. Next time I will explain how to get Scala running on Android.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Akka-Mobile? Right now it\u2019s an idea. It\u2019s my semester term project at the University of Applied Science in Rapperswil. In this blog post I give a short overview&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[243],"tags":[245,297,244,226],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/2016"}],"collection":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/comments?post=2016"}],"version-history":[{"count":4,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/2016\/revisions"}],"predecessor-version":[{"id":2022,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/posts\/2016\/revisions\/2022"}],"wp:attachment":[{"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/media?parent=2016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/categories?post=2016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gamlor.info\/wordpress\/wp-json\/wp\/v2\/tags?post=2016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}