Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Messaging everywhere: Service Bus for Windows Server & Windows Azure

Messaging everywhere: Service Bus for Windows Server & Windows Azure

Sending and receiving messages in software systems is the preferred method if you want to loosely couple systems, to achieve better isolation or greater scalability – whether it is large or small architectures. Christian Weyer shows how to use Microsoft’s Service Bus with its queues, topics, and publish/subscribe features to realize messaging solutions. He explains the basic architecture model, illustrated with common design patterns, and how to implement it on-premises and in the Windows Azure cloud. Come and see what is possible across various platforms (desktop, web, mobile).

Christian Weyer

March 06, 2013
Tweet

More Decks by Christian Weyer

Other Decks in Programming

Transcript

  1. 2 Christian Weyer • Solution architect and principal consultant at

    thinktecture • Focus on – distributed applications, service orientation – cloud computing – interoperability, cross device – pragmatic end-to-end solutions – Windows Server, ASP.NET, Web API, SignalR, WCF, Windows Azure • Microsoft MVP for Windows Azure (Architecture) • ASP.NET Web API Advisory Board Member • http://blogs.thinktecture.com/cweyer • [email protected] • @christianweyer think mobile!
  2. 3 Agenda • Integration via Messaging • Windows Azure Service

    Bus Relay • Service Bus Namespace and Access Control • Service Bus Brokered Messaging • Service Bus for Windows Server
  3. 4 Messaging • Traditional – Exchanging data via messages –

    Synchronous vs. Asynchronous – See http://www.eaipatterns.com/Messaging.html • Today – Bridge gaps for broad reach (physical, organizational etc.) – Different communication styles & patterns – Open platform and APIs
  4. 5 Cloud / On-Premises Integration • Cloud-hosted, reliable asynchronous messaging

    infrastructure with publish/subscribe • Cloud-based relay enabling secure NAT/firewall traversal for reach into on-premise assets • Service registry that allows organizing endpoints • Integration with access control functionality providing security gate with federated identity support
  5. 6 Cross-Site Federation (SaaS) • Endpoint Federation instead of Network

    Federation (VPN) • Non-intrusive, does not require network reconfiguration • Enables integration scenarios with: – Multi-tenancy – Minimal mutual trust – Minimal or no control over the on-premise networking environment
  6. 7 Trade Franchise Partner Integration • Enables integration across partners

    and franchise environments – Low trust – Limited control – Diverse sites with varying connectivity – Direct peer access and cloud access
  7. 8 Mobile Workforce / Customer Integration • Mobile devices are

    largely not “behind the firewall” • VPN solutions are largely impractical due to setup and management complexity
  8. 9 Large Scale Eventing / Command-Control • “Last Mile” problem

    of reaching into the consumer household • Reach consumer or industrial devices at scale • Broadcast event data at “utility scale” • Send targeted notifications based on geography or demographics
  9. 11 Expose Services from Anywhere to Anywhere – Outbound TCP

    (Ports 9350-9353) 9350 Unsecured TCP One-way (client) 9351 Secured TCP One-way (all listeners, secured clients) 9352 Secured TCP Rendezvous (all listeners except one-way) 9353 Direct Connect Probing Protocol (TCP listeners with direct connect) – Outbound HTTP (Port 80, Listeners) TCP equivalent tunnel with overlaid TLS/SSL formed over pair of HTTP requests Alternate connectivity path if outbound TCP is blocked – Outbound HTTPS (Port 443, Senders) – Relayed One-Way Unicast and Multicast – Relayed WCF NET.TCP with Direct Connect Option – Relayed WCF HTTP with support for REST and SOAP 1.1/1.2 – Endpoint protection with Access Control Key Capabilities Connectivity Options
  10. 12 Messaging Rendevouz Point in the Cloud Relayed / Brokered

    Connect Open Authenticate Authenticate (optional) 1 3 2 4 Trust Windows Azure Direct Connection (optional) 5 6 Sender Receiver ACS Service Bus
  11. 13 Relay Programming Model • Full WCF Programming Model –

    Bindings functionally symmetric with WCF • WebHttpRelayBinding (HTTP/REST) • BasicHttpRelayBinding (SOAP 1.1) • WS2007HttpRelayBinding (SOAP 1.2) • NetTcpRelayBinding (Binary transport) – Special Service Bus bindings • NetOnewayRelayBinding (multicast one-way) • NetEventRelayBinding (multicast one-way) – Transport binding elements for custom binding stacks • WebHttpRelayBinding provides full interoperability with any HTTP/REST client, BasicHttpRelayBinding with any SOAP client
  12. 14 Oneway • NetOnewayRelayBinding • All TCP and HTTP listeners

    use one-way as internal control channel • 60KB message size limit • One-way only • No rendezvous overhead
  13. 15 Oneway • NetOnewayRelayBinding • All TCP and HTTP listeners

    use one-way as internal control channel • 60KB message size limit • One-way only • No rendezvous overhead
  14. 16 Event • NetEventRelayBinding • Small-scale synchronous multicast • 60KB

    message size limit • One-way only • No rendezvous overhead
  15. 17 Rendezvous (TCP & HTTP) • NetTcpRelayBinding, WebHttpRelayBinding, BasicHttpRelayBinding, WS2007RelayBinding

    • Rendezvous handshake • Bi-directional • Net.Tcp full duplex • No message size limit • Load distribution available
  16. 18 Hybrid Connect • Special Mode of NetTcpRelayBinding (TcpRelayConnectionMode.Hybrid) •

    Starts as relayed connection • Performs NAT probing and behavior prediction • Establishes direct connection and upgrades if possible • Takes large transfers off the Relay • No transfer charges, lower latency
  17. 19 Service Bus Architecture - Namespaces • Naming tree –

    ATOM feed at the root for discovery – Management via REST on the ATOM feed hierarchy • “Infinite” depth – Factually: 32 segments, 450 character path limit • Entities own the namespace tree leaves • Any branch can be differently secured with Access Control Service (ACS) https://yourapp.servicebus.windows.net/foo/bar/baz
  18. 20

  19. 21 Service Bus Architecture - Access Control • Special relationship

    between Service Bus and ACS – Each SB namespace has a ‘buddy’ namespace in ACS • ‘yourapp.servicebus.windows.net’ • ‘yourapp-sb.accesscontrol.windows.net’ • ‘-sb’ namespaces – Preconfigured relying party for Service Bus namespace root • Can‘t be deleted, system-managed signing key, uses default rule group – Preconfigured service identity ‘owner’ • Can’t be deleted, configured as super user via default rule group • Tokens issued for ‘owner’ assigned ‘Listen’, ‘Send’, and ‘Manage’
  20. 22 Service Bus Rights and Claims • Service Bus defines

    one authorization claim type with three possible values that indicate the authorized operation(s) • ‘net.windows.servicebus.action’ – ‘Send’: permit ‘send’ operations on a Service Bus entity – ‘Listen’: permit ‘send’ or ‘receive’ operations on a Service Bus entity – ‘Manage’: permit management operations like creating, inspecting, or deleting Service Bus entities • You can federate your STS with ACS/SB
  21. 26 Programming Model Choices Brokered Messaging Apps / Consumers NetMessagingBinding

    .NET Service Bus Messaging API .NET WCF Service Model SB Messaging Protocol (net.tcp, proprietary) AMQP 1.0 Service Bus C/C++ (incl Embedded) Apache Proton-C HTTP(S) PHP client Node.js client Python client Java/JMS Apache Qpid JMS AMQP 1.0 Any HTTP client
  22. 27 Connectivity Options • AMQP (Advanced Message Queuing Protocol) 1.0

    – OASIS standard, growing base of clients across many platforms – AMQPS TCP 5671, AMQP TCP 5672 – Preview status, general availability later this year • "SBMP" Service Bus Messaging Protocol – Only supported by .NET client, Microsoft proprietary, based on WCF's NetTcp – TCP port 9354 or HTTP tunneling over port 443 or port 80 • HTTPS – TCP 443 – RFC2616 – majority of Service Bus features available for any HTTPS client
  23. 28 Delivery Options • Receive and Delete – Fastest. Message

    lost if receiver crashes or transmission fails. • Peek Lock – Message is locked when retrieved. Reappears on broker when not deleted within lock timeout. • Session + Peek Lock – Message is locked along with all subsequent messages w/ same session-id ensuring order
  24. 29 Messages • Brokered messaging properties are not SOAP headers

    • Properties are key/value pairs that may very well carry payloads • It’s not uncommon to have messages with empty message bodies • Message bodies are useful for a single opaque payload not exposed to the broker (e.g. encrypted content)
  25. 33 Subscription Filters • Filter conditions operate on message properties

    and are expressed in SQL’92 syntax – InvoiceTotal > 10000.00 OR ClientRating <3 – ShipDestCtry = ‘USA’ AND ShipDestState=‘WA’ – LastName LIKE ‘V%’ • Filter actions may modify/add/remove properties as message is selected – SET AuditRequired = 1
  26. 34 Pricing Windows Azure Service Bus Messages Relay Hours $0.01

    per 10,000 messages $0.10 per 100 relay hours (at a given address) Messages over 64KB in size will be charged an additional message for each additional 64KB of data (rounded up) This meter applies to relays as well as queues, topics, subscriptions, and message buffers There is no relay hour charge if you are only using Service Bus queues, topics/subscriptions, or message buffers
  27. 35 Windows Azure Service Bus Integration Routing Coordination Transformation Content-based

    routing, document transformation, and process coordination Service Management Naming, Discovery Monitoring ? Consistent management surface and service observation capabilities Messaging Queuing Pub/Sub Reliable Transfer Reliable, transaction- aware cloud messaging infrastructure for business apps Connectivity Service Relay Protocol Tunnel Eventing, Push Rich options for interconnecting apps across network boundaries Service Bus for Windows Server
  28. 37 Cloud vs. On-Premises Differences Cloud Server Tenancy • Multi

    tenant service • Subscribers and Namespaces • Deployment options • Namespaces for isolation Scale • Completely owned by service provider (Microsoft); • Scale out by adding more SQL Azure instances and Roles • Scale up by adding resources • Scale out by adding more SQL servers or nodes to the farm Authentication and Authorization ACS Windows; OAuth Addressing servicebus.windows.net • Path-based schema (FQDN) • Authority-based schema (DNS) Quotas Known quotas Configured by administrator Manageability & monitoring Windows Azure Service Bus management portal Deployment, configuration, capacity, health monitoring
  29. 38 Summary • Service Bus is a powerful beast •

    Pull & push-style messaging to enable various communication & integration scenarios – Relayed Messaging – Brokered Messaging – Bridge gaps • Open platform & APIs – REST APIs as well as native protocols • Service Bus is available in Windows Azure and for Windows Server – On Windows Server Brokered Messaging only – API parity modulo naming scheme & authentication • Ever growing messaging ecosystem & product
  30. 39 Resources • http://blogs.thinktecture.com/cweyer • [email protected] • Windows Azure Service

    Bus – https://www.windowsazure.com/en- us/home/features/messaging/ – https://www.windowsazure.com/en-us/develop/net/how-to- guides/service-bus-topics/ • Service Bus for Windows Server – http://msdn.microsoft.com/en-us/library/jj193012