IoT http://rickgaribay.net/category/62.aspx IoT en-US Rick G. Garibay rickgaribay@hotmail.com Subtext Version 1.9.5.176 Service Assisted Communications on Microsoft Azure http://rickgaribay.net/archive/2014/11/11/service-assisted-communications-on-microsoft-azure.aspx <p>I had the privilege of presenting at Azure Conf in Channel9 studios a couple of weeks ago. This is the second time I’ve had the pleasure to present at AzureConf (see my 2012 talk on <a href="http://channel9.msdn.com/events/windowsazure/AzureConf2012/A01">WebSockets</a> here:<a title="http://channel9.msdn.com/events/windowsazure/AzureConf2012/A01" href="http://channel9.msdn.com/events/windowsazure/AzureConf2012/A01">http://channel9.msdn.com/events/windowsazure/AzureConf2012/A01</a>)</p> <p>I covered a ton of content in just over 60 minutes including a command demo with a Fez Spider board and Azure Service Bus and a sneak peak of Azure Device Gateway (code-name Reykjavik) deployment on my Azure subscription to demonstrate deployment, telemetry, inquires and commands with a software emulator. </p> <center> <br /><iframe height="288" src="//channel9.msdn.com/Events/Microsoft-Azure/AzureConf-2014/Service-Assisted-Device-Communications-on-Microsoft-Azure/player" frameborder="0" width="512" allowfullscreen="allowfullscreen"></iframe> <br /></center><center><a href="http://bit.ly/1DBVLxk" target="_blank">Direct Link to Channel9 http://bit.ly/1DBVLxk</a> <br /> <br /><iframe height="400" marginheight="0" src="//www.slideshare.net/slideshow/embed_code/41430245" frameborder="0" width="476" marginwidth="0" scrolling="no"></iframe></center><center></center><img src="http://rickgaribay.net/aggbug/372.aspx" width="1" height="1" /> Rick G. Garibay http://rickgaribay.net/archive/2014/11/11/service-assisted-communications-on-microsoft-azure.aspx Tue, 11 Nov 2014 23:20:51 GMT http://rickgaribay.net/archive/2014/11/11/service-assisted-communications-on-microsoft-azure.aspx#feedback http://rickgaribay.net/comments/commentRss/372.aspx http://rickgaribay.net/services/trackbacks/372.aspx Visual Studio Live Redmond &ndash; 8/18 to 8/21 http://rickgaribay.net/archive/2014/08/11/visual-studio-live-redmond-ndash-818-to-821.aspx <div align="center"> <h1>The Goods... </h1> <br /> Thank you Redmond, 1105 Media, Microsoft, fellow speakers and all attendees for a great show. I had a blast! <br /> <table><tbody> <tr> <td><iframe height="400" marginheight="0" src="//www.slideshare.net/slideshow/embed_code/38229557" frameborder="0" width="476" marginwidth="0" scrolling="no"></iframe> <br />Code: <a href="https://github.com/rickggaribay/neurl">https://github.com/rickggaribay/IoT</a> </td> <td> </td> <td><iframe height="400" marginheight="0" src="//www.slideshare.net/slideshow/embed_code/38229551" frameborder="0" width="476" marginwidth="0" scrolling="no"></iframe> <br />Code: <a href="https://github.com/rickggaribay/neurl">https://github.com/rickggaribay/neurl</a> </td> </tr> </tbody></table> </div> +++ <p> </p> <p>I’m thrilled to be speaking at VS Live Redmond next week. The show starts on Monday August 18th and goes through Thursday the 21st on Microsoft campus in Redmond, WA. </p> <p>Events in Redmond a<a href="http://bit.ly/RDSPK10"><img title="RDSPK10 (1)" style="border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; margin: 15px 10px; display: inline; border-top-width: 0px" border="0" alt="RDSPK10 (1)" align="left" src="http://rickgaribay.net/images/rickgaribay_net/WindowsLiveWriter/VisualStudioLiveRedmond818to821_E9B6/RDSPK10%20(1)_3.jpg" width="184" height="154" /></a>re always a special treat as it gives everyone a chance to see the campus, interact with product team members and as always, meet and hang out with some of the best, most recognized speakers in the industry like Ted Neward, Michael Collier, Brian Noyes, Eric Boyd, Rachel Appel, Miguel Castro, Rocky Lhotka, Andrew Brust- the list goes on.</p> <p>I’ll be delivering two Azure focused presentations on the Internet of Things and API development with NodeJS.</p> <p>Since there is only so much space available for the abstracts themselves, I thought I’d elaborate a bit on what you can expect from each session in this short post. You can find more details about both talks on the VS Live Redmond <a href="http://bit.ly/RDSPK10" target="_blank">website</a> or go directly to the abstracts by following the links below.</p> <p><strong>From the Internet of Things to Intelligent Systems: A Developer's Primer</strong></p> <p>In this talk, I lay the foundation for IoT and why you, as a developer should care. I’ll show off a handful of devices ranging from Arduino, Netduino and Fez Spider and demonstrate a number of common patterns currently in the wild including default communication, brokered and service assisted. We’ll explore the challenges that exist today in supporting commands, notifications, inquiries and telemetry. I’ll then spend some time giving you an in-depth tour of Reykjavik, Microsoft’s code name for its reference architecture focused on delivering highly scalable messaging fabrics for modern IoT solutions. </p> <p>We’ll take a look at the reference architecture and how it maps to components on Microsoft Azure. I’ll then demonstrate what a first-class Reykjavik device looks like and demonstrate live telemetry and commands for an end-to-end tour of Reykjavik. I’ve been spending a lot of time with Clemens and team over the last several weeks so this promises to be an inside look at the reference architecture and general shape of things you're unlikely to find publically anywhere else.</p> <p>Learn more about this talk here: <a title="http://bit.ly/VSLRIOT" href="http://bit.ly/VSLRIOT">http://bit.ly/VSLRIOT</a> or follow the conversation on Twitter #VSLTH04</p> <p><strong>Building APIs with NodeJS on Microsoft Azure Websites</strong></p> <p>This is a talk that I’ve been working on for several months now and continues to evolve. As I discuss in my <a href="http://bit.ly/1nT4K6h" target="_blank">latest article in CODE Magazine</a>, it started off as a spike for teaching myself basic NodeJS and kind of evolved into a little project for work that needed a hosting environment. After exploring various options, Azure Websites made the most sense and this talk focuses on the key features and functionality of a little URL shortening API along with key ALM considerations like IDE, unit testing, continuous integration and deployment. </p> <p>I’ll walk you through each step I took in building this API from scratch and deploy it live to Azure Websites as well as show you some really cool things you can do with the Kudu console when things go awry (as they almost always do in a live demo :-)) </p> <p>More about this talk here: <a title="http://bit.ly/VSLRAPI" href="http://bit.ly/VSLRAPI">http://bit.ly/VSLRAPI</a> or follow the conversation on Twitter  #VSLW09</p> <p>If you plan on attending either of my sessions please stop by and say hi or after the talk. I hope to see you there!</p><img src="http://rickgaribay.net/aggbug/371.aspx" width="1" height="1" /> Rick G. Garibay http://rickgaribay.net/archive/2014/08/11/visual-studio-live-redmond-ndash-818-to-821.aspx Mon, 11 Aug 2014 23:38:01 GMT http://rickgaribay.net/archive/2014/08/11/visual-studio-live-redmond-ndash-818-to-821.aspx#feedback http://rickgaribay.net/comments/commentRss/371.aspx http://rickgaribay.net/services/trackbacks/371.aspx Visual Studio Live Chicago Recap: From the Internet of Things to Intelligent Systems - A Developer's Primer http://rickgaribay.net/archive/2014/05/09/visual-studio-live-chicago-recap-from-the-internet-of-things.aspx <p>I had the pleasure of presenting at Visual Studio Live! Chicago this week. Here is a recap of my second talk “From the Internet of Things to Intelligent Systems- A Developer’s Primer (if you’re looking for a recap of my “Building APIs with NodeJS on Microsoft Azure Websites” you can find it <a href="http://bit.ly/1gwnz9E">here</a>).</p> <p>While analysts and industry pundits can’t seem to agree on just how big IoT will be in the next 5 years, one thing they all agree on is that it will be big. From a bearish 50B internet connected devices by 2020, to a more moderate 75B and bullish 200B, all analysts agree that IoT is going to be big. But the reality is that IoT isn’t something that’s coming. It’s already here and this change is happening faster than anyone could have imagined. Microsoft predicts that by 2017, the entire space will represent over $1.7T in market opportunity spanning from manufacturing and energy to retail, healthcare and transportation. </p> <p>While it is still very early, it is clear to see that the monetization opportunities at this level of scale are tremendous. As I discussed in my talk, the real opportunity for organizations across all industries is two-fold. First, the <em><strong>data</strong></em> <em><strong>and analytical insights</strong></em> that the telemetry (voluntary data shared by the devices) will provide will change the way companies plan, execute and the rate at which they will adapt and adjust to changing conditions in their physical environments. This brings new meaning to decision support and no industry will be left untouched in this regard. These insights will lead to intelligent systems that are capable of taking <strong><em>action at a distance</em> </strong>based either on pre-configured rules that interpret this real-time device telemetry or other command and control logic that prompts communication with device. </p> <p>As a somewhat trivial but useful example, imagine your coffee maker sending you an SMS asking you permission to approve a descaling job. Another popular example of a product that’s already had significant commercial success is the Nest thermostat. Using microcontrollers very similar to the ones I demonstrated, these are simple examples that are already possible today.</p> <p>Beyond the commercial space, another very real example is a project my team led for our client that involved streaming meter and sensor telemetry from a large downtown metroplex enabling real-time, dynamic pricing, up-to-the-minute views into parking availability and significant cost and efficiency savings by adopting a directed enforcement approach to ticketing. </p> <p>So, IoT is already everywhere and in many cases, as developers we’re already behind. For example, what patterns do you use for managing command and control operations? How do you approach addressability? How do you overcome resource constraints on devices ranging in size from drink coasters to postage stamps? How do you scale to hundreds and thousands of devices that are sharing telemetry data every few seconds? What about security? </p> <p>While 75 minutes is not a ton of time to tackle all of these questions, I walked the audience through the following four scenarios based on the definition of the Command message pattern in the "<a href="http://bit.ly/saccv">Service Assisted Communications</a>" paper that Clemens Vasters (@clemensv) at Microsoft published this February:</p> <p>1. Default Communication Model with Arduino - demonstrates the default communication model whereby the Arduino provides its own API (via a Web Server adapted by zoomcat). Commands are sent from the command source to the device in a point to point manner. </p> <p>2. Brokered Device Communication with Netduino Plus 2 - demonstrates an evolution from the point to point default communication model to a brokered approach to issuing device commands using MQTT. This demo uses the excellent M2MQTT library by WEB MVP Paolo Patierno (@ppatierno) as well as the MQTT plug-in for RabbitMQ (both on-premise and RabbitMQ hosted). </p> <p>3. Service-Assisted Device-Direct Commands over Azure Service Bus - applies the fundamental service assisted communications concepts evolving the brokered example to leverage Azure Service Bus using the Device Direct pattern (as opposed to Custom Gateway). As with the brokered model, the device communicates with a single endpoint in an outbound manner, but does not require a dedicated socket connection as with MQTT implicitly addressing occasionally disconnected scenarios, message durability, etc. </p> <p>In the final, capstone demo, “Service-Assisted Device-Direct Commands on the Azure Device Gateway”, I demonstrated the culmination of work dating back to June 2012 (in which Vasters first shared the concept of Service-Assisted Communications) which is now available as a reference architecture and fully functional code base for customers ready to adopt an IoT strategy today: </p> <p><a href="http://rickgaribay.net/images/rickgaribay_net/WindowsLiveWriter/RecapVisualStudioLiveChicago_E226/image_2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/WindowsLiveWriter/RecapVisualStudioLiveChicago_E226/image_thumb.png" width="640" height="227" /></a> </p> <p>As a set up for the demo, I discussed the Master and Partition roles. The Master role manages the deployment of partitions and the provisioning of devices into partitions using the command line tools that ship with the code base.</p> <p>In the demo, I provided a look at the instance of Reykjavik deployed on our Neudesic Azure account including the Master and Partition roles. I showed the Azure Service Bus entities for managing the ingress and egress of device messaging for command, notification, telemetry and inquiry traffic (The Device Gateway is currently capable of supporting 1024 partitions with each partition supporting 20K devices today) as well as the storage accounts responsible for device registration and storing partition configuration settings. </p> <p>I also discussed the protocols for connecting the device to the gateway (AMQP and HTTP are in the box and an MQTT adapter is coming very soon) and walked through the Telemetry Pump which dispatches telemetry messages to the registered telemetry adapter (Table Storage, HD Insight adapters, etc.) </p> <p>The demo wrapped up with a Reykjavik device sample consisting of a Space Heater emulator that I registered on the Neudesic instance of the Device Gateway to acquire it’s ingress and egress endpoints, initialize fan speed, rpm and begins to send telemetry messages to it’s outbox every 30 seconds (fully configurable). </p> <p>The beauty of the demo is in its simplicity. Commands are received via the device’s inbox and telemetry is shared via it’s outbox. The code is simple C# with no heavy frameworks which is really key to running on devices with highly constrained resources:</p> <div class="csharpcode"> <pre class="alt"><span class="lnum"> 1: </span><span class="kwrd">void</span> SendTelemetry()</pre> <pre><span class="lnum"> 2: </span> {</pre> <pre class="alt"><span class="lnum"> 3: </span> <span class="kwrd">this</span>.lastTelemetrySent = DateTime.UtcNow;</pre> <pre><span class="lnum"> 4: </span> </pre> <pre class="alt"><span class="lnum"> 5: </span> var tlm = <span class="kwrd">new</span> BrokeredMessage</pre> <pre><span class="lnum"> 6: </span> {</pre> <pre class="alt"><span class="lnum"> 7: </span> Label = <span class="str">"tlm"</span>,</pre> <pre><span class="lnum"> 8: </span> Properties =</pre> <pre class="alt"><span class="lnum"> 9: </span> {</pre> <pre><span class="lnum"> 10: </span> {<span class="str">"From"</span>, gatewayId},</pre> <pre class="alt"><span class="lnum"> 11: </span> {<span class="str">"Time"</span>, DateTime.UtcNow},</pre> <pre><span class="lnum"> 12: </span> {<span class="str">"tiv"</span>, (<span class="kwrd">int</span>) <span class="kwrd">this</span>.telemetryInterval.TotalSeconds},</pre> <pre class="alt"><span class="lnum"> 13: </span> {<span class="str">"fsf"</span>, <span class="kwrd">this</span>.fanspeedSettingRpmFactor},</pre> <pre><span class="lnum"> 14: </span> {<span class="str">"fss"</span>, <span class="kwrd">this</span>.fanSpeedSetting},</pre> <pre class="alt"><span class="lnum"> 15: </span> {<span class="str">"fon"</span>, <span class="kwrd">this</span>.fanOn},</pre> <pre><span class="lnum"> 16: </span> {<span class="str">"tsc"</span>, <span class="kwrd">this</span>.temperatureSettingC},</pre> <pre class="alt"><span class="lnum"> 17: </span> {<span class="str">"hon"</span>, <span class="kwrd">this</span>.heaterOn},</pre> <pre><span class="lnum"> 18: </span> {<span class="str">"ofr"</span>, <span class="kwrd">this</span>.lastObservedFanRpm},</pre> <pre class="alt"><span class="lnum"> 19: </span> {<span class="str">"otm"</span>, <span class="kwrd">this</span>.lastObservedTemperature}</pre> <pre><span class="lnum"> 20: </span> }</pre> <pre class="alt"><span class="lnum"> 21: </span> };</pre> <pre><span class="lnum"> 22: </span> </pre> <pre class="alt"><span class="lnum"> 23: </span> tlm.SessionId = Guid.NewGuid().ToString();</pre> <pre><span class="lnum"> 24: </span> </pre> <pre class="alt"><span class="lnum"> 25: </span> <span class="kwrd">this</span>.sender.SendWithRetryAsync(tlm);</pre> <pre><span class="lnum"> 26: </span> }</pre> </div> <style type="text/css"><![CDATA[ .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]></style> <p> </p> <p>A screenshot from the telemetry table populated by the Reykjavik Table Storage adapter is shown in the Neudesic Azure Storage Explorer below:</p> <p><a href="http://rickgaribay.net/images/rickgaribay_net/WindowsLiveWriter/RecapVisualStudioLiveChicago_E226/image_4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px" border="0" alt="image" src="http://rickgaribay.net/images/rickgaribay_net/WindowsLiveWriter/RecapVisualStudioLiveChicago_E226/image_thumb_1.png" width="644" height="450" /></a> </p> <p>As I discussed, this is an early point in a journey that will continue to evolve over time, but the great thing about this model is that everything I showed is built on Microsoft Azure so there’s nothing to stop you as a developer form building your own Custom Protocol Adapter and this is really the key to the thinking and philosophy around Device Gateway. </p> <p>It is still very early in this wave and every organization is going to have different devices, protocols and requirements. So while you’ll see investments in the most common protocols as you can already see like (AMQP, MQTT, and CoAp) the goal is to make this super pluggable and fully embrace custom protocol gateways that just plug in. </p> <p>As with the Protocol Adapters, there’s nothing to stop you from building your own Telemetry adapter or to use Azure Service Bus or BizTalk Services to move data on premise, etc. </p> <p>Still with me? Great. The links to my demo samples and more details on the talk are available here:</p> <p>Abstract: <a title="http://bit.ly/vsl-iot" href="http://bit.ly/vsl-iot">http://bit.ly/vsl-iot</a> </p> <p>Demo Samples: <a title="https://github.com/rickggaribay/IoT" href="https://github.com/rickggaribay/IoT">https://github.com/rickggaribay/IoT</a> </p> <p></p> <p>Oh, and if you missed the Chicago show, don’t worry! I’ll be repeating this talk in Redmond and Washington DC, so be sure to register now for early bird discounts: <a title="http://bit.ly/vslive14" href="http://bit.ly/vslive14">http://bit.ly/vslive14</a></p><img src="http://rickgaribay.net/aggbug/368.aspx" width="1" height="1" /> Rick G. Garibay http://rickgaribay.net/archive/2014/05/09/visual-studio-live-chicago-recap-from-the-internet-of-things.aspx Fri, 09 May 2014 23:41:19 GMT http://rickgaribay.net/archive/2014/05/09/visual-studio-live-chicago-recap-from-the-internet-of-things.aspx#feedback 1 http://rickgaribay.net/comments/commentRss/368.aspx http://rickgaribay.net/services/trackbacks/368.aspx IoT, Mobility, Hybrid Cloud, ESB Oh My! A Closer Look at the Neudesic Gartner AADI Demo http://rickgaribay.net/archive/2013/12/21/iot-mobility-hybrid-cloud-esb-oh-my-a-closer-look.aspx <p>Earlier this week, my colleague <a href="http://twitter.com/simonguest" target="_blank">@simonguest</a> <a href="http://simonguest.com/2013/12/12/ibeacon-demo-at-gartner-aadi/" target="_blank">posted a great summary</a> of the demo he and I built together for the <a href="http://www.gartner.com/technology/summits/na/applications/" target="_blank">Gartner AADI Summit</a> in Las Vegas week before last.<a href="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_8.png"><img style="border-bottom: 0px; border-left: 0px; margin: 5px 5px 5px 30px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_thumb_8.png" width="389" height="480" /></a> </p> <p>As Simon illustrates, the demo combined two areas we are thinking a lot about these days at Neudesic- enterprise mobility and Internet of Things. </p> <p>When we talk about enterprise mobility, we're not talking about mobile device management, governance or provisioning. Our focus is on unlocking the assets that live on premises, behind the firewall so that they are safely and securely exposed, composed and consumed by a variety of devices and composite business applications on the web.</p> <p>In this post, I’ll talk a little bit more about these two areas and dive into the back-end of the demo from a messaging and services perspective to give you a glimpse into the internals of the demo app.   </p> <p><strong><u>Exposing On-Premise Assets</u></strong></p> <p>The key unlocking event for enterprise mobility is enabling the ability to expose assets that live within an organization’s traditional datacenter. These assets include things like other apps, LOB systems, ERPs and databases. In the most traditional sense, the way this problem has been solved is by determining what assets need to be made available, standing up hardware on a DMZ and specifying which inbound ports allow which kind of traffic. Unfortunately, there’s really nothing too innovative about this approach as it is the way we’ve been solving this problem for nearly 20 years. </p> <p>Today, there are many enterprise mobility vendors out there offering an appliance based offering which extends this approach to address things like security, hardware compression, etc., but the agility of these solutions is questionable as they still required CapEx spend, time and resources to provision and manage. </p> <p>Another kind of on-premise asset you will be hearing more and more about involves sensors and devices that communicate with software and other devices. This Machine to Machine (M2M) communication will be revolutionary in domain<a href="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" border="0" alt="image" align="left" src="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_thumb.png" width="191" height="93" /></a>s such as transportation, retail, logistics, oil and gas, manufacturing, etc. as they will enable the ability to yield new insights that will at first transform business and then become key to survival. One such device is known as iBeacon.</p> <p>These devices, about the width and half the length of a stick of gum run on Bluetooth Low Energy (BLE) and thus require very little power. These beacons transmit a unique identifier along with signal strength which can then be used to calculate proximity. </p> <p>You can easily imagine a scenario where a retailer provides a free app that interacts with you in the store as you approach these iBeacons. As you might imagine, the back end of the app would learn your behaviors and preferences and target you with interesting offers to influence your browsing and buying habits as well as crowd sourcing what ideal retail layouts look like based on the tons of data that could be collected and modeled. Another scenario might involve tracking shipping containers on trucks. Today, 5.9 RFID technology dominates this space but the amount of infrastructure required to read the tags compared to what can be accomplished with a handful of iBeacons and a handheld device is disruptive indeed. To illustrate this in our demo, our iBeacons communicated directly with iOS and Android handsets, with literally no set up or tear down, allowing us to enumerate, update and “check into” the beacons that were placed throughout the conference floor. </p> <p>For the check in scenario, as you approached an iBeacon, the app would raise an event allowing you to check in to that location. The app then sent a message over the Gartner guest conference WIFI network to a server hosted in our datacenter in Irvine, CA running <a href="http://products.neudesic.com/features" target="_blank">Neuron ESB</a>. The server sits behind our firewall and no inbound ports are open because our IT policy rightfully prohibits it. Instead, a single outbound port is opened by Neuron over an Azure Service Bus Relay which allows for secure, bi-directional messaging for a number of APIs that we implemented which I’ll cover in more detail next.</p> <p><strong><u>Composing and Consuming</u></strong></p> <p>As you can see in the demo sample architecture, we exposed a REST head over Azure Service Bus which provided the external messaging fabric for communicating with the apps running on iOS and Android in the Gartner exhibition hall. Using Neuron’s messaging and processing capabilities, we implemented the following 4 APIs:</p> <p> </p> <table border="0" cellspacing="0" cellpadding="2" width="882"><tbody> <tr> <td valign="top" width="424"> <p><strong></strong></p> <ul> <li><strong>REGISTER BEACON</strong> <br />PUT /beacons <br />{ id: "&lt;&lt;GUID&gt;&gt;", name: "Neudesic Booth, Expo Hall"} </li> </ul> <p> </p> <p> <br /></p> <ul> <li><strong>LOOK UP BEACON</strong> <br />GET /beacons <br />[{ id: "&lt;&lt;GUID&gt;&gt;", name: "Beacon name"}, {id: "&lt;&lt;GUID&gt;&gt;", name: "Beacon name"}] (Array) </li> </ul> <p> </p> <p> <br /></p> <ul> <li><strong>GET ALL BEACONS</strong> <br />GET /beacons/:id <br />{ id: "&lt;&lt;GUID&gt;&gt;", name: "Beacon name"} </li> </ul> <p> </p> <p> <br /></p> <ul> <li><strong>CHECK IN TO BEACON</strong> <br />PUT /beacons/:id/checkin <br />{ userid: "&lt;&lt;facebookid&gt;&gt;" } </li> </ul> <p></p> </td> <td valign="top" width="456"><a href="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_3.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_thumb_3.png" width="251" height="480" /></a> <br /><font size="1">The Android version of the app the weekend before the conference. We used Xamarin to build a consistent UX for iOS as well. The iBeacons were re-registered with the actual locations of the booths on the conference floor within a few seconds. </font></td> </tr> </tbody></table> <p> </p> <p>To create a connection to Azure Service Bus, we simply created a Client Connector within a Service Endpoint in Neuron as shown below:</p> <p><a href="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_thumb_4.png" width="617" height="414" /></a> </p> <p>Neuron hosts an instance of the WCF NetMessagingBinding and creates a virtual service endpoint using the URI shown above. </p> <p>In order to route the requests from the app to the right logic, we implemented a simple controller called “Beacon Router” using a Neuron Process. Using a Decision step, we added 4 branches for each API:</p> <p><a href="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_thumb_5.png" width="441" height="480" /></a> </p> <p>Each Decision Step has a condition which returns true or false. If the condition returns true, the steps within the branch are executed. If not, the Process evaluates each branch until a match is found our returns a 404, Resource not Found. </p> <p>Here is a look at the the Check In Condition:</p> <p><a href="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_thumb_6.png" width="640" height="422" /></a> </p> <p>As you can see, we used a simple UriTemplate to define the template for the Check In API. The URI is stored in the ESB message context within the MessageHeader.To property. If the template matches the actual URI, we return true and the steps within the branch execute in sequence. </p> <p>The next step that fires is the Publish step. We included this step for testing purposes to serve as Wire Tap on the messages that reach the branch. In this case, this was useful for inspecting the message off the wire by configuring a subscribing party and using our Neuron Test Client to inspect the message:</p> <p><a href="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_7.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/image_thumb_7.png" width="568" height="480" /></a> </p> <p>This little trick aside, the Publish step is very powerful in that it allows you to asynchronously publish a message on a topic for other subscribers to pick up. Think of Scatter Gather as a good example. </p> <p>The next step you’ll notice is a Call Process step. This step simply allows you to call a nested Process which is helpful in factoring your Process (note that we could have chosen to asynchronously execute a nested process by wrapping it inside a Parallel step).</p> <p>The Check In process starts with a Push step. This step stores the current message for later use. </p> <p>This was required because we needed to first determine if the iBeacon location was valid before allowing a check in. The way Neuron Processes work is that the message is modified by each step allowing for very powerful enrichment and transformation of the message. However, since there can only be one message in context at any time, the current message is overwritten by the message we crafted up for the ODBC step which follows. </p> <p>In this case, we used the ODBC step to query SQL Server for the iBeacon guid. The ODBC step expects a message that conforms to it’s interface, a simple XML syntax for defining the query:</p> <div class="csharpcode"> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 1: </span><span class="kwrd">string</span> sql = String.Empty; </pre> <pre><span class="lnum"> 2: </span> <a href="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/SNAGHTMLd1870c0.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="SNAGHTMLd1870c0" border="0" alt="SNAGHTMLd1870c0" align="right" src="http://rickgaribay.net/Images/CustomContent/ModernMobilityatGartnerAADI_D46E/SNAGHTMLd1870c0_thumb.png" width="352" height="1234" /></a></pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 3: </span>sql += <span class="str">"&lt;Statement type=\"Text\" sql=\"SELECT * FROM [dbo].[Beacon] WHERE BeaconGuid =?\"&gt;"</span>; </pre> <pre><span class="lnum"> 4: </span>sql += <span class="str">"&lt;Parameters&gt;"</span>; </pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 5: </span>sql += <span class="str">"&lt;Parameter type=\"varchar\" name=\"@BeaconGuid\" value=\""</span> + beaconId + <span class="str">"\"/&gt;"</span>; </pre> <pre><span class="lnum"> 6: </span>sql += <span class="str">"&lt;/Parameters&gt;"</span>; </pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 7: </span>sql += <span class="str">"&lt;/Statement&gt;"</span>; </pre> <pre><span class="lnum"> 8: </span> </pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 9: </span>context.Data.FromXml(sql);</pre> </div> <style type="text/css"><![CDATA[ .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]></style> <p> </p> <p>Note line 9 above replaces the message in the context with this new message. The ODBC step executes the query based on the latest context and returns the result:</p> <pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">QueryResults</span><span class="kwrd">&gt;</span> <span class="kwrd">&lt;</span><span class="html">QueryResult</span><span class="kwrd">&gt;</span> <span class="kwrd">&lt;</span><span class="html">Id</span><span class="kwrd">&gt;</span>2<span class="kwrd">&lt;/</span><span class="html">Id</span><span class="kwrd">&gt;</span> <span class="kwrd">&lt;</span><span class="html">BeaconGuid</span><span class="kwrd">&gt;</span>1.1<span class="kwrd">&lt;/</span><span class="html">BeaconGuid</span><span class="kwrd">&gt;</span> <span class="kwrd">&lt;</span><span class="html">BeaconName</span><span class="kwrd">&gt;</span>Neudesic Booth<span class="kwrd">&lt;/</span><span class="html">BeaconName</span><span class="kwrd">&gt;</span> <span class="kwrd">&lt;</span><span class="html">QueryResults</span><span class="kwrd">&gt;</span> <span class="kwrd">&lt;</span><span class="html">QueryResult</span><span class="kwrd">&gt;</span></pre> <style type="text/css"><![CDATA[ .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]></style> <p></p> <p>Next, we used a Decision step to check to see if the ODBC step yielded the iBeacon we looked up:</p> <div class="csharpcode"> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 1: </span>var xml = context.Data.ToXmlDocument(); </pre> <pre><span class="lnum"> 2: </span>var node = xml.GetElementsByTagName(<span class="str">"QueryResult"</span>); </pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 3: </span><span class="kwrd">return</span> node.Count &gt; 0;</pre> </div> <style type="text/css"><![CDATA[ .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]></style> <p>If the node count is not zero, we know we have a match. Otherwise, we issue a 404 since the resource could not be found. </p> <p>Recall that at the beginning of the process execution, the first thing we did was push the message into temporary storage so that we could retrieve it later. Once we determined that the iBeacon exists, we pop the message back into context so that we can grab the iBeacon id from the URI and the user id of the user (in this case, a facebook email address) from the original HTTP message body.</p> <p>To perform the chec kin, we simply did an INSERT into a SQL Server table called CheckIn. The Code step includes the following code, which as before, the ODBC step will consume and perform the unit of work. </p> <p>Since the iBeacon ID is part of the URI, we use UriTemplate again to determine a match and then extract the {id} parameter from the URI:</p> <div class="csharpcode"> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 1: </span>System.UriTemplate template = <span class="kwrd">new</span> System.UriTemplate(<span class="str">"/beacons/{id}/checkin"</span>);</pre> <pre><span class="lnum"> 2: </span>Uri uri = <span class="kwrd">new</span> Uri(context.Data.GetProperty(<span class="str">"MessageHeader"</span>,<span class="str">"To"</span>));</pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 3: </span>Uri baseUri = <span class="kwrd">new</span> Uri(<span class="str">"https://"</span> + uri.Host);</pre> <pre><span class="lnum"> 4: </span>var match = template.Match(baseUri, uri);</pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 5: </span> </pre> <pre><span class="lnum"> 6: </span>var beaconId = match.RelativePathSegments[1];</pre> </div> <style type="text/css"><![CDATA[ .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]></style> <p>From there, we do some formatting and grab the user id from the JSON message payload that was provided in the HTTP body: </p> <div class="csharpcode"> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 1: </span>System.Web.Script.Serialization.JavaScriptSerializer serializer = <span class="kwrd">new</span> System.Web.Script.Serialization.JavaScriptSerializer();</pre> <pre><span class="lnum"> 2: </span> </pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 3: </span>Neudesic.TPG.GartnerAADI.Model.CheckIn checkIn = <span class="kwrd">new</span> </pre> <pre><span class="lnum"> 4: </span>System.Web.Script.Serialization.JavaScriptSerializer().Deserialize&lt;Neudesic.TPG.GartnerAADI.Model.CheckIn&gt;(jsonString);</pre> </div> <style type="text/css"><![CDATA[ .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]></style> <p>Finally, we build the INSERT statement and load the new message context: </p> <div class="csharpcode"> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 1: </span><span class="kwrd">string</span> sql = String.Empty;</pre> <pre><span class="lnum"> 2: </span> </pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 3: </span>sql += <span class="str">"&lt;Statement type=\"Text\" sql=\"INSERT INTO [dbo].[CheckIn]([UserId],[BeaconGuid],[Date]) VALUES(?,?,?)\"&gt;"</span>;</pre> <pre><span class="lnum"> 4: </span>sql += <span class="str">"&lt;Parameters&gt;"</span>;</pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 5: </span>sql += <span class="str">"&lt;Parameter type=\"varchar\" name=\"@UserId\" value=\""</span> + checkIn.UserId + <span class="str">"\"/&gt;"</span>;</pre> <pre><span class="lnum"> 6: </span>sql += <span class="str">"&lt;Parameter type=\"varchar\" name=\"@BeaconGuid\" value=\""</span> + beaconId + <span class="str">"\"/&gt;"</span>;</pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 7: </span>sql += <span class="str">"&lt;Parameter type=\"varchar\" name=\"@Date\" value=\""</span> + DateTime.Now.ToString() + <span class="str">"\"/&gt;"</span>;</pre> <pre><span class="lnum"> 8: </span>sql += <span class="str">"&lt;/Parameters&gt;"</span>;</pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 9: </span>sql += <span class="str">"&lt;/Statement&gt;"</span>;</pre> <pre><span class="lnum"> 10: </span> </pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 11: </span>context.Data.FromXml(sql);</pre> </div> <style type="text/css"><![CDATA[ .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]></style> <p>If all goes well, we issue an HTTP 200 back to the client: </p> <div class="csharpcode"> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 1: </span>context.Data.Http = <span class="kwrd">new</span> HttpMessage();</pre> <pre><span class="lnum"> 2: </span>context.Data.Http.StatusCode = System.Net.HttpStatusCode.OK;</pre> <pre style="width: 73%; height: 20px" class="alt"><span class="lnum"> 3: </span>context.Data.FromString(<span class="str">""</span>);</pre> </div> <style type="text/css"><![CDATA[ .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]></style> <p>Otherwise we own up to the problem being on our end and return a 500 (with some internal logging of course). </p> <p>The Register API is implemented in much the same way. We check to see if the iBeacon exists and if so, do an update, otherwise insert a new record. Thus, this API supports initial standing up of the beacons as well as managing the names as the beacons moved from development to the expo floor. </p> <p>For the GET APIs, we again used ODBC steps to query for a single or all beacons and returned a single or an array of beacons respectively as you can see in the BeaconRouter screenshot at the beginning of this walkthrough. </p> <p><u><strong>Summary</strong></u></p> <p>As you can probably guess, Simon and I had a lot of fun building this demo and the folks at the conference seemed to find it interesting too :-) </p> <p>There are unlimited possibilities once you unlock the ability to safely and securely transcend network, security and business boundaries behind the firewall. And if agility isn’t enough to compel you to think differently about how you expose and compose your enterprise assets for external consumption by mobile devices today, the proliferation of devices- and I’m not talking about tablets or phones- expected to reach in the excess of 250 billion by 2025, will challenge every industry to think differently about their enterprise messaging and mobility strategy. </p><img src="http://rickgaribay.net/aggbug/362.aspx" width="1" height="1" /> Rick G. Garibay http://rickgaribay.net/archive/2013/12/21/iot-mobility-hybrid-cloud-esb-oh-my-a-closer-look.aspx Sat, 21 Dec 2013 15:49:41 GMT http://rickgaribay.net/archive/2013/12/21/iot-mobility-hybrid-cloud-esb-oh-my-a-closer-look.aspx#feedback http://rickgaribay.net/comments/commentRss/362.aspx http://rickgaribay.net/services/trackbacks/362.aspx