{"id":497,"date":"2019-03-15T10:18:04","date_gmt":"2019-03-15T09:18:04","guid":{"rendered":"http:\/\/blog.zhaw.ch\/splab\/?p=497"},"modified":"2019-03-15T16:37:57","modified_gmt":"2019-03-15T15:37:57","slug":"building-a-sample-mqtt-based-application-on-openwhisk","status":"publish","type":"post","link":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/","title":{"rendered":"Building a Sample MQTT-based Application on OpenWhisk"},"content":{"rendered":"\n<p>In two previous blog posts &#8211; <a href=\"https:\/\/blog.zhaw.ch\/splab\/2019\/02\/21\/deploying-openwhisk-on-kubernetes-on-openstack\/\">here<\/a> and <a href=\"https:\/\/blog.zhaw.ch\/splab\/2019\/02\/28\/reliable-openwhisk-deployment-on-kubernetes-with-persistent-storage\/\">here<\/a> &#8211; we discussed our experience with deploying OpenWhisk on Kubernetes on OpenStack. As applied researchers at the Service Prototyping Lab, we are investigating potential use cases for such setups and for FaaS-based applications in general. In this blog post, we will therefore describe how we built a sample MQTT-based application that shows OpenWhisk in action for sensor data processing for future Internet of Things and smart dust scenarios.<\/p>\n\n\n\n<p>The basic idea of the application is that it consumes data from an MQTT feed, stores it in a database and provides a means to access the database via a web UI. The architecture of the application is shown in the figure below. The application is based on this <a href=\"http:\/\/jamesthom.as\/blog\/2016\/06\/15\/openwhisk-and-mqtt\/\">blog post<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9\" alt=\"\" \/><figcaption>Sample Application Architecture<\/figcaption><\/figure><\/div>\n\n\n\n<!--more-->\n\n\n\n<p>As can be seen from the figure, the motion sensor publishes messages to a specific topic. The trigger service provider subscribes to the same topic and fires OpenWhisk triggers that invoke the action <code>addReadingToDb<\/code> that inserts each message to a CouchDB database. A user can point a browser at the <code>renderHtml.js<\/code> web action which returns a HTML page to show the latest readings. Within the page, there\u2019s a JavaScript function that invokes the <code>getLatestTenReadings<\/code> web action every 10 seconds to refresh the page.<br><\/p>\n\n\n\n<p>The IoT motion sensor and the MQTT broker were provided by our friends at the <a href=\"https:\/\/blog.zhaw.ch\/splab\/for-researchers\/cloud-accounting-and-billing\/\">Cloud Accounting and Billing Initiative<\/a> and were simply based on a Raspberry Pi with an attached motion sensor publishing to an MQTT broker. The motion sensor publishes a message to a specific topic ( <code>lexxito<\/code> in this case) every time it detects motion. The simple message contains a JSON object with just two keys: time and status.<\/p>\n\n\n\n<p>We needed a persistent service that managed subscriptions from OpenWhisk trigger creations to topics and fired a trigger every time a new message was received. We used the service provider from the blog post mentioned above. However, we had to make some modifications to it as it assumed &nbsp;<a href=\"https:\/\/console.bluemix.net\/catalog\/services\/cloudant\">Cloudant<\/a> &#8211; the IBM proprietary data store &#8211; as a backend. As we are using vanilla OpenWhisk, we needed an alternative and we decided to use <a href=\"https:\/\/couchdb.apache.org\/\">CouchDB<\/a> instead. The modified code can be found <a href=\"https:\/\/github.com\/mohammed-ali-1\/openwhisk_mqtt_feed\">here<\/a>.(We also found and fixed a bug with the <code>remove_trigger<\/code> function in the <code>feed_controller.js<\/code> file which threw an error every time we tried to delete a trigger).<\/p>\n\n\n\n<p>We then deployed a CouchDB instance on our Kubernetes cluster in a separate namespace using the Helm package manager following <a href=\"https:\/\/github.com\/helm\/charts\/tree\/master\/incubator\/couchdb\">these instructions<\/a>. Next, we had to configure the CouchDB database so that it can be used by the service provider. To do that, we created a database in our CouchDB instance with the name <code>topic_listeners<\/code> by running the following:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -X PUT \"http:\/\/username:password@COUCHDB_HOST:COUCHDB_PORT\/topic_listeners\"<\/code><\/pre>\n\n\n\n<p>This call returns the very informative response: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\"ok\":true}<\/code><\/pre>\n\n\n\n<p>Which indicates that the configuration of the database was successful.<br><\/p>\n\n\n\n<p>Then, we needed to add some views to our database. <a href=\"https:\/\/docs.couchdb.org\/en\/2.2.0\/ddocs\/views\/index.html#guide-to-views\">Views<\/a> in CouchDB are used to query and filter documents. We created a file called <code><a href=\"https:\/\/gist.github.com\/mohammed-ali-1\/e390d3f9725cf0001f19f432e9332fa4\">views.json<\/a><\/code> and added it to CouchDB by running the following command:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -X PUT \"http:\/\/username:password@COUCHDB_HOST:COUCHDB_PORT\/topic_listeners\/_design\/subscriptions\" --data-binary @views.json<\/code><\/pre>\n\n\n\n<p>We had to create the <code>readings<\/code> database that will be used by the <code>addReadingToDb<\/code> action on CouchDB by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -X PUT \"http:\/\/username:password@COUCHDB_HOST:COUCHDB_PORT\/readings\"<\/code><\/pre>\n\n\n\n<p>Then, we were ready to deploy the service provider on our Kubernetes cluster by containerizing it first using the provided <a href=\"https:\/\/github.com\/mohammed-ali-1\/openwhisk_mqtt_feed\/blob\/master\/provider\/Dockerfile\">Dockerfile<\/a>, pushing the docker container to <a href=\"https:\/\/cloud.docker.com\/u\/mohammedalameen94\/repository\/docker\/mohammedalameen94\/mqtt_service_provider\">Docker Hub<\/a>, and then creating a <code><a href=\"https:\/\/gist.github.com\/mohammed-ali-1\/551f8efe1852c62052d2b43a1cf4cf59\">deployment.yaml<\/a><\/code> file for it.<br><\/p>\n\n\n\n<p>Then, we deployed the service provider by running:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ kubectl apply -f deployment.yaml<\/code><\/pre>\n\n\n\n<p>And to expose the pod as a service, we ran:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ kubectl expose pod mqtt-provider --port='3000' --type='NodePort'<\/code><\/pre>\n\n\n\n<p>With that, the service provider was now ready to accept trigger registrations.<br><\/p>\n\n\n\n<p>We then turned our attention to configuring OpenWhisk to connect to the service provider in order to register triggers with it. To do that, we created a shared package under the <code>\/whisk.system<\/code> namespace to make it accessible to all users, with the name <code>mqtt<\/code> by running the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk package create \\\n--shared yes \\\n-p provider_endpoint \"http:\/\/SERVICE_PROVIDER_HOST:SERVICE_PROVIDER_NODEPORT\/mqtt\" mqtt<\/code><\/pre>\n\n\n\n<p>And we added some description to the package:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk package update mqtt \\\n-a description 'The mqtt package provides functionality to connect to MQTT brokers'<\/code><\/pre>\n\n\n\n<p>Next, we created a feed action and associated it with the <code>mqtt<\/code> package. A feed action is an action that manages the lifecycle of triggers. The code for the feed action used in our sample application can be found <a href=\"https:\/\/github.com\/mohammed-ali-1\/openwhisk_mqtt_feed\/blob\/master\/feed_action.js\">here<\/a>. <br><\/p>\n\n\n\n<p>The feed action will take care of creating and removing triggers. This means that when a user would like to create a trigger, i.e. subscribe to a specific topic on an MQTT broker and fire triggers whenever a new message is published on the topic, the feed action will send a request to the service provider in order to register the trigger with the specific topic on the MQTT broker.<br><\/p>\n\n\n\n<p>We added the feed action to the <code>mqtt<\/code> package by running the following command:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk action create -a feed true mqtt\/mqtt_feed feed_action.js<\/code><\/pre>\n\n\n\n<p>Once we had the feed action configured, we were able to associate a trigger with the <code>lexxito<\/code> topic on the MQTT broker. To do that, we ran the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk trigger create \/guest\/feed_trigger \\\n--feed \/whisk.system\/mqtt\/mqtt_feed \\\n-p topic 'lexxito' \\\n-p url 'mqtt:\/\/mqtt.demonstrator.info' \\\n-p authKey $WHISK_GUEST_AUTH \\\n-p triggerName '\/guest\/feed_trigger'<\/code><\/pre>\n\n\n\n<p>Next, we created the action <code>addReadingToDb<\/code> that will insert each message to the CouchDB database. The code for the action can be viewed <a href=\"https:\/\/gist.github.com\/mohammed-ali-1\/8075cada8a347c1dafeb1d308cab5228\">here<\/a>.<br><\/p>\n\n\n\n<p>The <code>addReadingToDb<\/code> action is a NodeJS package that used the <code><a href=\"https:\/\/www.npmjs.com\/package\/sync-request\">sync-request<\/a><\/code> NPM module to perform a POST request to the readings database on CouchDB. This was achieved by following the instructions from <a href=\"http:\/\/jamesthom.as\/blog\/2016\/11\/28\/npm-modules-in-openwhisk\/\">this<\/a> blog post on how to package NPM dependencies for OpenWhisk actions.<br><\/p>\n\n\n\n<p>Next, we added the <code>AddReadingToDb<\/code> action to OpenWhisk by running the following command:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk action create addReadingToDb \\\n--kind nodejs:default addReadingToDb.zip<\/code><\/pre>\n\n\n\n<p>Next, we had to create an OpenWhisk rule that connected the <code>feed_trigger<\/code> to the <code>addReadingToDb<\/code> action so that every time the <code>feed_trigger<\/code> is fired, the <code>addReadingToDb<\/code> action gets invoked. An OpenWhisk rule associates a trigger with an action, invoking the action when the associated trigger is fired.<br><\/p>\n\n\n\n<p>To create the rule, we ran the following:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk rule create mqttRule \/guest\/feed_trigger addReadingToDb<\/code><\/pre>\n\n\n\n<p>Now every time a new message is published on the topic <code>lexxito<\/code>, a trigger is fired by the trigger service provider carrying with it the contents of the message to the <code>addReadingToDb<\/code> action. The action will then be invoked and will add the contents of the message to the <code>readings<\/code> database.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The UI<\/strong><\/h2>\n\n\n\n<p>We then turned our attention to the user-facing component of our sample application.<br><\/p>\n\n\n\n<p>We wanted to serve static content within OpenWhisk without using any external services like GitHub Pages, for example. Since OpenWhisk doesn\u2019t provide a convenient way to serve static content, we looked into using OpenWhisk web actions to return a HTML page.<br><\/p>\n\n\n\n<p>An OpenWhisk web action is an action that\u2019s accessible via REST API without needing credentials nor the OpenWhisk CLI. That is, upon the creation of a web action, a URL is created for it that can be hit to invoke the web action.<br><\/p>\n\n\n\n<p>We created a web action, <code>renderHtml.js<\/code> that returns a HTML page to show the latest readings from the <code>readings<\/code> database. The code for the <code>renderHtml.js<\/code> action can be viewed <a href=\"https:\/\/gist.github.com\/mohammed-ali-1\/b372ba940d7f8816e327a55d9448efc5\">here<\/a>.<br><\/p>\n\n\n\n<p>To create the <code>renderHtml.js<\/code> web action, we ran the following command:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk action create renderHtml renderHtml.js --web true<\/code><\/pre>\n\n\n\n<p>Within the HTML code that <code>renderHtml.js<\/code> returns, there\u2019s a JavaScript script that invokes another web action, <code>getLatestTenReadings<\/code>, every ten seconds in order to refresh the page. The <code>getLatestTenReadings<\/code> web action queries the <code>readings<\/code> database and returns the ten most-recent entries in the <code>readings<\/code> database.<br><\/p>\n\n\n\n<p>The code for <code>getLatestReadings<\/code> can be viewed <a href=\"https:\/\/gist.github.com\/mohammed-ali-1\/adb947050211c6011e0783084117fe4a\">here<\/a>.<br><\/p>\n\n\n\n<p>Similar to the <code>addReadingToDb<\/code> action, this is a NodeJS package that uses the <code>sync-request<\/code> NPM module to retrieve the ten most-recent entries from the readings database.<br><\/p>\n\n\n\n<p>We created the <code>getLatestTenReadings<\/code> web action by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk action create getLatestTenReadings \\\n--kind nodejs:default getLatestTenReadings.zip \\\n--web true<\/code><\/pre>\n\n\n\n<p>And we got the URL to <code>getLatestTenReadings<\/code> by running the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk action get getLatestTenReadings --url<\/code><\/pre>\n\n\n\n<p>We got the URL to the <code>renderHtml<\/code> web action by running the following:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wsk action get renderHtml --url<\/code><\/pre>\n\n\n\n<p>Finally, by pointing the browser at this endpoint, the dynamic MQTT data should be visible.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lessons Learnt<\/h2>\n\n\n\n<p>Getting a basic application running on OpenWhisk that uses a custom external feed, requires database support, and serves static content is not a trivial task. Perhaps some of the issues that we faced are addressed in commercial variants of OpenWhisk, but the developer experience of getting a simple app operational on vanilla OpenWhisk is not so straightforward for what is touted to be a very developer-oriented platform.<br><\/p>\n\n\n\n<p>Nonetheless, OpenWhisk remains an exciting platform with a lot of potential. But, from our experience, there is still too much friction associated with getting a basic application running.<br><\/p>\n<div class=\"pt-sm\">Schlagw\u00f6rter: <a href=\"http:\/\/blog.zhaw.ch\/splab\/tag\/faas\/\">faas<\/a>, <a href=\"http:\/\/blog.zhaw.ch\/splab\/tag\/howto\/\">howto<\/a>, <a href=\"http:\/\/blog.zhaw.ch\/splab\/tag\/iot\/\">iot<\/a>, <a href=\"http:\/\/blog.zhaw.ch\/splab\/tag\/mqtt\/\">mqtt<\/a>, <a href=\"http:\/\/blog.zhaw.ch\/splab\/tag\/openwhisk\/\">openwhisk<\/a>, <a href=\"http:\/\/blog.zhaw.ch\/splab\/tag\/sensors\/\">sensors<\/a>, <a href=\"http:\/\/blog.zhaw.ch\/splab\/tag\/serverless\/\">serverless<\/a><br><\/div>","protected":false},"excerpt":{"rendered":"<p>In two previous blog posts &#8211; here and here &#8211; we discussed our experience with deploying OpenWhisk on Kubernetes on OpenStack. As applied researchers at the Service Prototyping Lab, we are investigating potential use cases for such setups and for FaaS-based applications in general. In this blog post, we will therefore describe how we built [&hellip;]<\/p>\n","protected":false},"author":397,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[4],"tags":[7,51,52,53,50,54,8],"features":[],"class_list":["post-497","post","type-post","status-publish","format-standard","hentry","category-research","tag-faas","tag-howto","tag-iot","tag-mqtt","tag-openwhisk","tag-sensors","tag-serverless"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Building a Sample MQTT-based Application on OpenWhisk - Service Prototyping Lab<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building a Sample MQTT-based Application on OpenWhisk\" \/>\n<meta property=\"og:description\" content=\"In two previous blog posts &#8211; here and here &#8211; we discussed our experience with deploying OpenWhisk on Kubernetes on OpenStack. As applied researchers at the Service Prototyping Lab, we are investigating potential use cases for such setups and for FaaS-based applications in general. In this blog post, we will therefore describe how we built [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/\" \/>\n<meta property=\"og:site_name\" content=\"Service Prototyping Lab\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-15T09:18:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-15T15:37:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9\" \/>\n<meta name=\"author\" content=\"Mohammed Al-Ameen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohammed Al-Ameen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/\"},\"author\":{\"name\":\"Mohammed Al-Ameen\",\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/#\/schema\/person\/3fc7624a4a118d37d1130b0400362f0b\"},\"headline\":\"Building a Sample MQTT-based Application on OpenWhisk\",\"datePublished\":\"2019-03-15T09:18:04+00:00\",\"dateModified\":\"2019-03-15T15:37:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/\"},\"wordCount\":1327,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9\",\"keywords\":[\"faas\",\"howto\",\"iot\",\"mqtt\",\"openwhisk\",\"sensors\",\"serverless\"],\"articleSection\":[\"Research\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/\",\"url\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/\",\"name\":\"Building a Sample MQTT-based Application on OpenWhisk - Service Prototyping Lab\",\"isPartOf\":{\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9\",\"datePublished\":\"2019-03-15T09:18:04+00:00\",\"dateModified\":\"2019-03-15T15:37:57+00:00\",\"author\":{\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/#\/schema\/person\/3fc7624a4a118d37d1130b0400362f0b\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#primaryimage\",\"url\":\"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9\",\"contentUrl\":\"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\/\/blog.zhaw.ch\/splab\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building a Sample MQTT-based Application on OpenWhisk\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/#website\",\"url\":\"https:\/\/blog.zhaw.ch\/splab\/\",\"name\":\"Service Prototyping Lab\",\"description\":\"A Blog of the ZHAW Zurich University of Applied Sciences\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.zhaw.ch\/splab\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.zhaw.ch\/splab\/#\/schema\/person\/3fc7624a4a118d37d1130b0400362f0b\",\"name\":\"Mohammed Al-Ameen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/94977c59a64d3341d6db72d6958d1408413b56018f07c205a130d19d7ee3bb47?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/94977c59a64d3341d6db72d6958d1408413b56018f07c205a130d19d7ee3bb47?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/94977c59a64d3341d6db72d6958d1408413b56018f07c205a130d19d7ee3bb47?s=96&d=mm&r=g\",\"caption\":\"Mohammed Al-Ameen\"},\"url\":\"https:\/\/blog.zhaw.ch\/splab\/author\/alam\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Building a Sample MQTT-based Application on OpenWhisk - Service Prototyping Lab","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/","og_locale":"en_GB","og_type":"article","og_title":"Building a Sample MQTT-based Application on OpenWhisk","og_description":"In two previous blog posts &#8211; here and here &#8211; we discussed our experience with deploying OpenWhisk on Kubernetes on OpenStack. As applied researchers at the Service Prototyping Lab, we are investigating potential use cases for such setups and for FaaS-based applications in general. In this blog post, we will therefore describe how we built [&hellip;]","og_url":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/","og_site_name":"Service Prototyping Lab","article_published_time":"2019-03-15T09:18:04+00:00","article_modified_time":"2019-03-15T15:37:57+00:00","og_image":[{"url":"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9","type":"","width":"","height":""}],"author":"Mohammed Al-Ameen","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mohammed Al-Ameen","Estimated reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#article","isPartOf":{"@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/"},"author":{"name":"Mohammed Al-Ameen","@id":"https:\/\/blog.zhaw.ch\/splab\/#\/schema\/person\/3fc7624a4a118d37d1130b0400362f0b"},"headline":"Building a Sample MQTT-based Application on OpenWhisk","datePublished":"2019-03-15T09:18:04+00:00","dateModified":"2019-03-15T15:37:57+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/"},"wordCount":1327,"commentCount":0,"image":{"@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#primaryimage"},"thumbnailUrl":"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9","keywords":["faas","howto","iot","mqtt","openwhisk","sensors","serverless"],"articleSection":["Research"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/","url":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/","name":"Building a Sample MQTT-based Application on OpenWhisk - Service Prototyping Lab","isPartOf":{"@id":"https:\/\/blog.zhaw.ch\/splab\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#primaryimage"},"image":{"@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#primaryimage"},"thumbnailUrl":"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9","datePublished":"2019-03-15T09:18:04+00:00","dateModified":"2019-03-15T15:37:57+00:00","author":{"@id":"https:\/\/blog.zhaw.ch\/splab\/#\/schema\/person\/3fc7624a4a118d37d1130b0400362f0b"},"breadcrumb":{"@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#primaryimage","url":"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9","contentUrl":"https:\/\/lh4.googleusercontent.com\/Y4MDfFFZoOcdlb7RUg0MbmLFVbmLDafqHiYidv1Rc1QNejZ67NKbKQlsdrXjvLvcqv9dCMGqWqJ665E57Nl1iCQ_ige1bLKa1fO6T9wcGoETQkzdJxrJtoeWvWeVUvFLlsqFIul9"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.zhaw.ch\/splab\/2019\/03\/15\/building-a-sample-mqtt-based-application-on-openwhisk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/blog.zhaw.ch\/splab\/"},{"@type":"ListItem","position":2,"name":"Building a Sample MQTT-based Application on OpenWhisk"}]},{"@type":"WebSite","@id":"https:\/\/blog.zhaw.ch\/splab\/#website","url":"https:\/\/blog.zhaw.ch\/splab\/","name":"Service Prototyping Lab","description":"A Blog of the ZHAW Zurich University of Applied Sciences","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.zhaw.ch\/splab\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/blog.zhaw.ch\/splab\/#\/schema\/person\/3fc7624a4a118d37d1130b0400362f0b","name":"Mohammed Al-Ameen","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/94977c59a64d3341d6db72d6958d1408413b56018f07c205a130d19d7ee3bb47?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/94977c59a64d3341d6db72d6958d1408413b56018f07c205a130d19d7ee3bb47?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/94977c59a64d3341d6db72d6958d1408413b56018f07c205a130d19d7ee3bb47?s=96&d=mm&r=g","caption":"Mohammed Al-Ameen"},"url":"https:\/\/blog.zhaw.ch\/splab\/author\/alam\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/posts\/497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/users\/397"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/comments?post=497"}],"version-history":[{"count":27,"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/posts\/497\/revisions"}],"predecessor-version":[{"id":528,"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/posts\/497\/revisions\/528"}],"wp:attachment":[{"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/media?parent=497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/categories?post=497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/tags?post=497"},{"taxonomy":"features","embeddable":true,"href":"https:\/\/blog.zhaw.ch\/splab\/wp-json\/wp\/v2\/features?post=497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}