Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Azure Service Bus : under the hood

3,282 views

Published on

This session was delivered in Venice at IoT Day 2015.
It is focused on AMQP protocol fundamentals and how Azure Service Bus works under the hood with this protocol : from packet format to architecture, from communication to advantages/disadvantages.

Published in: Technology
  • Be the first to comment

Azure Service Bus : under the hood

  1. 1. IoT day 2015 Azure Service Bus : under the hood AMQP protocol fundamentals Paolo Patierno Microsoft MVP for Windows Embedded @ppatierno
  2. 2. IoT day 2015 Sponsor
  3. 3. Who am I ? Contacts •Senior Software Engineer (Leonardo Ricerche S.r.l.) •Microsoft MVP for Windows Embedded ”... constantly moving between the devices and the cloud ...” •«DotNetCampania» member • https://paolopatierno.wordpress.com •«TinyCLR.it» member • http://www.tinyclr.it •«Embedded101» board of director member • http://www.embedded101.com/Blogs/PaoloPatierno.aspx •Linkedin • http://it.linkedin.com/in/paolopatierno •Contacts • [twitter] @ppatierno • [email] ppatierno@live.com • [skype] paolopat80
  4. 4. Agenda •IoT communication patterns •Azure Service Bus intro … • Queues • Topics/Subscriptions • Event Hubs •… under the cover : AMQP protocol • Introduction • Architecture • Communication • How it fits the patterns •Demo
  5. 5. IoT Communication Patterns Telemetry Information flows from device to other systems for conveying status changes in the device Inquiries Requests from devices looking to gather required information or asking to initiate activities Commands Commands from other systems to a device or a group of devices to perform specific activities Notifications Information flows from other systems to a device or a group for conveying status changes in the world 1:N 1:N
  6. 6. Azure Service Bus … Queues •Competing Consumers pattern • all consumers read from same stream (queue) •Message consumed by a single consumer
  7. 7. Azure Service Bus … Topics •Publish/Subscribe pattern • each consumer reads from its subscription (a copy of message on related topic) •Message consumed by more subscribers (use filters) Subs
  8. 8. Azure Service Bus … Event Hubs •Partitioned Consumers pattern
  9. 9. Proprietary messaging protocols •Difficult to port applications • Requires re-coding all applications •Difficult to integrate • Application level bridges to move messages and translate message formats •Restricted platform support • Limited to whatever vendor provides
  10. 10. Advanced Message Queuing Protocol 1.0 •Open, standard messaging protocol • OASIS (since 2012/10) and ISO/IEC (since 2014/05) • Enables cross-platform apps to be built using brokers, libraries and frameworks from different vendors •Features • Efficient : binary connection-oriented protocol • Reliable : “fire and forget” to reliable, “exactly once” delivery • Portable data representation : cross-platform, full-fidelity exchange • Flexible : client-client, client-broker and broker-broker topologies • Broker model independent : no requirements on broker internals
  11. 11. Microsoft said … “Microsoft congratulates the AMQP community on approval of AMQP version 1.0 as an OASIS Standard. As an open and interoperable messaging protocol that can scale from mobile clients to the cloud, AMQP has benefitted from the participation of technical experts from around the world, and the achievement of this important milestone will lead to continued growth in the AMQP ecosystem. We look forward to working with the community to promote AMQP-based interoperability and innovation.” -- Scott Guthrie
  12. 12. AMQP 1.0 client libraries Language Library C# Service Bus .NET Client Library, AMQP.Net Lite Java Apache Qpid Java Message Service (JMS) client IIT SwiftMQ Java client C Apache Qpid Proton-C PHP Apache Qpid Proton-PHP Python Apache Qpid Proton-Python Ruby Apache Qpid Proton-Ruby Perl Apache Qpid Proton-Perl NodeJS Node AMQP 1.0
  13. 13. AMQP : containers and nodes •architecture • wire protocol • data types system with compact binary encoding •container • client contains producer and/or consumer • broker contains entities (ex. queues, topics/subscriptions, event hubs) •node • producer sends messages • consumer receives messages • entities store and/or forward messages
  14. 14. AMQP : transport client producer (consumer) broker entity container containerconnection session link node node multiplexing frames on sessions and links transport indipendent
  15. 15. open (max frame size, channel max, timeout) AMQP : communication  Open •Open TCP connection •Open ”connection” •Begin ”session” •Attach ”link” Container Container header AMQP / SASL handshake open (max frame size, channel max, …) begin (in/out window, handle max, …) begin (in/out window, handle max, …) attach (name, source, target, handle, …) attach (name, source, target, handle, …) open TCP connection open «connection» begin «session» attach «link» header AMQP / SASL handshake
  16. 16. AMQP : communication  Send •Send messages • to queue • to topic • to event hub Producer Container attach (name, source, target, handle, …) attach (name, source, target, handle, …) attach «link» flow (in/out window, link credit, …) flow control transfer (delivery id/tag, settled, …) disposition (first, last, settled, state, …) sending message transfer (delivery id/tag, settled, …) disposition (first, last, settled, state, …) sending messages transfer (delivery id/tag, settled, …) transfer (delivery id/tag, settled, …)
  17. 17. AMQP : communication  Receive •Receive messages • from queue • from subscription • from event hub Consumer Container attach (name, source, target, handle, …) attach (name, source, target, handle, …) attach «link» flow (in/out window, link credit, …) flow control transfer (delivery id/tag, settled, …) disposition (first, last, settled, state, …) receiving message transfer (delivery id/tag, settled, …) disposition (first, last, settled, state, …) receiving messages transfer (delivery id/tag, settled, …) transfer (delivery id/tag, settled, …)
  18. 18. end AMQP : communication  Close •Detach ”link” •End ”session” •Close ”connection” •Close TCP connection Container Container detach (handle, close, …) end close close detach «link» end «session» close «connection» detach (handle, close, …)
  19. 19. AMQP : Telemetry •Data transfer •Messages settled Device Server transfer (<resource>) transfer (<resource>) transfer (<resource>) settlement (based on QoS) settlement (based on QoS) flow in_queue
  20. 20. AMQP : Inquiry •Correlation between inquiry request and response Device Server transfer (<info>, replyTo, messageId) transfer (<info>, correlationId = messageId) settlement (based on QoS) settlement (based on QoS) in_queue out_queue
  21. 21. AMQP : Command •Correlation between command request and response Device transfer (<cmd>, replyTo, messageId) transfer (<result>, correlationId = messageId) settlement (based on QoS) settlement (based on QoS) Serverin_queue out_queue
  22. 22. AMQP : Notification •Notification received •Messages settled Device Server transfer (<notifiy>) settlement (based on QoS) transfer (<notify>) settlement (based on QoS) flow in_queue
  23. 23. AMQP : Claim Based Security (CBS) token •Build a token based on publisher name, expire time, URI, key, … •Send the token to the $cbs endpoint and specify a ReplyTo •Receive status code of the request from the above ReplyTo Device Server transfer (<token>, replyTo, messageId) transfer (<status code>, correlationId = messageId) settlement (based on QoS) settlement (based on QoS) $cbs <replyTo>
  24. 24. AMQP : messages •message • header • annotations • system properties (ex. correlationId, replyTo, TTL, …) • custom/user properties • «opaque» body (encoded as you want, ex. binary, XML, JSON, …) •message metadata •most times body empty, all values as properties •filter on properties •properties can be changed «on fly»
  25. 25. AMQP : main features •messaging middleware • asynchronous : produce and consumer decoupled • credit based to receive +5
  26. 26. AMQP : main features •more messaging patterns • load balancing and competing consumers (ex. on a queue) • publish/subscribe (ex. on topic/subscription) • partitioned consumers (ex. on event hubs) • messages redirection to queues based on filters • request/response w/ «correlation id» and «replyTo» •session and transactional message transfer
  27. 27. AMQP : advantages •efficient • binary connection-oriented • ”flow control” credit based • packet size 60 bytes •reliable • Quality of Service (best effort, at least once, exactly once) •security • SSL/TLS • SASL (Simple Authentication and Security Layer) • decople authentication from application layer
  28. 28. Netduino 3 WiFi •STM32 Cortex-M4 •2 MB dual-bank flash •256 KB RAM •WiFi module (TI CC 3100) •Go-Bus ports •Micro SD •.Net Micro Framework •Visual Studio 2013 •Azure Enabled (SSL/TLS)
  29. 29. IoT day 2015 Access to Service Bus with AMQP
  30. 30. References •Microsoft Azure • Service Bus : http://azure.microsoft.com/en-us/services/service-bus/ • Event Hubs : http://azure.microsoft.com/en-us/services/event-hubs/ •AMQP • Official web site : http://www.amqp.org • AMQP .Net Lite : http://amqpnetlite.codeplex.com/ • Azure SB Lite : http://azuresblite.codeplex.com/ • Azure SB Lite Examples : https://github.com/ppatierno/azuresblite-examples • Apache Qpid: https://qpid.apache.org/

×