410 likes | 659 Views
Driving the Azure Service Bus. Scott Klueppel Solutions Architect SOAlutions , Inc. # jaxcodeimpact @ kloopdogg. Azure Service Bus. Agenda. - Feature Overview - Management Portal / Tools - Relayed vs. Brokered Messaging - Cloud Design Patterns
E N D
Driving theAzure Service Bus Scott Klueppel Solutions Architect SOAlutions, Inc. #jaxcodeimpact @kloopdogg
Azure Service Bus Agenda • - Feature Overview • - Management Portal / Tools • - Relayed vs. Brokered Messaging • - Cloud Design Patterns • - Building Hybrid/Cross-Platform Systems
Azure Service Bus Feature Overview Management Portal Tools
What is the Service Bus? Azure Service Bus • - Cross-platform middleware • - Unified set of messaging capabilities • - Request/Response • - One-way • - Queued • - Publish/Subscribe
Windows Azure SDK Azure Service Bus • - SDK contains client libraries • - MS Committed to backwards compatibility
Demo Management Portal Tools
Relayed Messaging Features Demo
What is a relay? Relays • A centralized service that offers connectivity options for clients and servers communicating in challenging network scenarios • Permits one-way, request/response messaging • Supports SOAP, WS-*, optimized for WCF • Service hosts are “Listeners” • Clients only call the relay service
How does it work? Relays 7 Relay message (load balancing) Service Bus 8 Deliver message Access Control Service 3 Open RelayConnection Send message 6 On-Premise 2 Return Token Return Token 5 WCF Service Remote 1 4 Client SendShared Secret SendShared Secret
Scenario 1: Network Infrastructure Relays On-Premise Relay Corporate Web App WCF Service Firewall NAT Client Firewall NAT Other Service Dynamic IPs No LB/ACE
Scenario 2: Emergency Use Relays On-Premise Relay Corporate Web App WCF Service Firewall NAT Client Other Service Firewall NAT WCF Service
Scenario 3: Roaming Devices Relays On-Premise Corporate . Web App WCF Service Client Firewall NAT Other Service Firewall NAT Relay Coffee Shop . Client
Considerations Relays • If there are no listeners, the service is unavailable • No automatic scaling for high bursts of traffic • Load balancing is not configurable • Ports 9350-9353 (outbound only)
Demo Convert to Relay Load balancing
Brokered Messaging Features Demos
What is brokered messaging? • Sender makes asynchronous calls • Messages are durably stored in a broker • Broker holds messages until receiver is available • Ideal for distributed or occasionally-connected systems • Service Bus offers queues and topics … and soon event hubs
Queues Queues • Messages are durably stored until consumed • Messages pulled from queue by one or more competing consumers • Benefits: - Temporal decoupling - Load leveling - Load balancing
Topics (and Subscriptions) Topics • Messages are durably stored until consumed • Messages are sent to one or more subscriptions - Messages pulled from subscriptions by one or more competing consumers • Benefits: - Temporal decoupling - Load leveling - Load balancing
Show me the messages Queue Topic Queues Topics (with subscriptions) Client Service Service Service Sub {color=red} Client Sub {true}
Creating broker objects Queues namespaceManager.CreateQueue("issues"); Topics namespaceManager.CreateTopic("telemetry-ingestion"); Subscriptions namespaceManager.CreateSubscription("telemetry-ingestion", // topic name"Dashboard", // subscription name new SqlFilter("Color = 'red'")); // filter (optional)
The BrokeredMessage class • Body (object or stream) • Properties (KVP) • Has two primary constructors: BrokeredMessage() - Empty body BrokeredMessage(object) - Object must be serializable (uses DataContractSerializer)
Receiving Brokered Messages • Poll using “Receive” operations (client API) • Use messaging bindings with a WCF service
Using queues Queues • Create a queue client • Send a message • Receive a message varuri = ServiceBusEnvironment.CreateServiceUri("sb", namespace, String.Empty); TokenProvider credentials = TokenProvider.CreateSharedSecretTokenProvider(IssuerName, IssuerKey); MessagingFactoryfactory = MessagingFactory.Create(uri, credentials); QueueClientqueueClient= factory.CreateQueueClient("TestQueue"); TimeSpanreceiveTimeout= TimeSpan.FromSeconds(5); while((message = queueClient.Receive(receiveTimeout)) != null) { //TODO: Do work message.Complete(); } BrokeredMessageissueMsg = new BrokeredMessage(issue); queueClient.Send(issueMsg);
Using topics Topics • Send a message • Receive a message MessagingFactoryfactory = MessagingFactory.Create(uri, credentials); SubscriptionClientsubscriptionClient = factory.CreateSubscriptionClient(topicName, subscriptionName); TimeSpanreceiveTimeout = TimeSpan.FromSeconds(5); while((message = subscriptionClient.Receive(receiveTimeout)) != null) { //TODO: Do work message.Complete(); } MessagingFactoryfactory = MessagingFactory.Create(uri, credentials); TopicClienttopicClient= factory.CreateTopicClient(topicName); BrokeredMessageissueMsg = new BrokeredMessage(issue); topicClient.Send(issueMsg);
Auto-forwarding Scale out for more overall subscriptions • Auto-forwarding topics and queues - Improves overall performance Fan in from several queues Forward to (maybe delayed) processing queues Topic Client Queue Queue Subscription Topic Topic Subscription Subscription Client Topic Auto-forwarding Auto-forwarding Queue Client Subscription Queue Subscription Client Auto-forwarding Topic Subscription Subscription Queue Subscription Subscription Queue Client Topic Subscription Subscription Subscription
Squeezing Performance • Use SBMP over HTTP • Reuse clients → fewer connections • Client-side batching (async only) • Express queues/topics • Partitioning → distributed internal store
Demo Queues Topics
Patterns at Work Queue-Based Load Leveling Priority Queues
Queue-Based Load Leveling • Maximize availability • Increased scalability • Control costs
Priority Queue • Prioritization ofmessage processing • Maximizeperformance • Minimize operationalcosts
Cross-Platform AMQP Devices
Azure Service Bus Multiple Protocol Support Service Bus Protocols - SBMP • High performance • .NET/Windows only - HTTP • Lower performance • High reach - AMQP • High performance • High reach
Azure Service Bus AMQP • Enables cross-platform systems to be built using brokers and frameworks from different vendors • Open, standard messaging protocol - OASIS AMQP 1.0 Standard (in progress since 2008, completed in 2013) • Service Bus .NET Client Library (C#) • Apache Qpid JMS/IIT SwiftMQ (Java) • Apache Qpid Proton (C, PHP, Python)
Azure Service Bus Use Case: Sensors/Devices AMQP Ingestion / Analysis Coordinator • ZigBee Radio • Solar Cell(s) • Batteries • Sensors • Temperature • Moisture • Light • Sound
Azure Service Bus Event Hubs (Preview) • Facilitates cloud-scale ingestion - Telemetry data - Events • Millions of events per second (up to 1 GB/s) • Support for AMQP and HTTP • Each partition - 1MB/s ingress and 2MB/s egress - Needs exactly one dedicated worker process
Demo AMQP Linux/Python
What did we talk about? Azure Service Bus Features Some cloud design patterns Cross-platform goodness
code.org Programming for any age
Questions? Scott Klueppel Solutions Architect SOAlutions, Inc. #jaxcodeimpact @kloopdogg
References Cloud Design Patterns (P&P)http://msdn.microsoft.com/en-us/library/dn568099.aspx Apache Qpid Protonhttp://qpid.apache.org/proton/
Thank you! Scott Klueppel Solutions Architect SOAlutions, Inc. #jaxcodeimpact @kloopdogg