560 likes | 787 Views
MID312. Windows Azure AppFabric Service Bus : New Capabilities. Clemens Vasters Principal Technical Lead Microsoft Corporation. The Cloud. All Apps Move To The Cloud. No They Don’t. Integrated Enterprise. Loyalty. Travel. Vendor Market. Health. Campaign. CRM. LOB. ERP. HR.
E N D
MID312 Windows Azure AppFabric Service Bus: New Capabilities Clemens Vasters Principal Technical Lead Microsoft Corporation
Integrated Enterprise Loyalty Travel Vendor Market Health Campaign CRM LOB ERP HR Time Card BI Shop BI Portal Benefits
Very Few Go ‘All In’ On The Cloud. Sourced Vendor Market Firewall ? ? NAT Security Realm Loyalty Travel Health Campaign CRM LOB ERP HR Time Card BI Shop BI Portal Benefits
So How Can This Work? Sourced Vendor Market Firewall ? ? NAT Security Realm Loyalty Travel Health • Existing Web Service Endpoint. • No Mutual Trust Between Systems, VPN not an option. • Sits Behind Firewall and NAT. • Not built for non-corporate identity access control Campaign CRM LOB ERP HR Time Card BI Shop BI Portal Benefits
Connectivity Relay Service Bus Frontend Nodes Ctrl NLB 2 3 1 outbound socket rendezvous outbound socket connect Ctrl Forwarder Sender Receiver 4
Connectivity Relay Service Bus Frontend Nodes • Using Outbound Connections Only • No open inbound firewall/NAT ports • Outbound connections default to TCP • Fall back to HTTP when needed • Guarded by Datacenter Firewall • Secured with Access Control Receiver
… in medias res …. Service Bus Commercially Available since January 2010 Brand-New Community Technology Preview Available Now
We’re Adding a Whole New Set Of Capabilities Connectivity Service Relay Protocol Tunnel Eventing, Push Messaging Queuing Pub/Sub Reliable Transfer Service Management Naming, Discovery Monitoring Integration Routing Coordination Transformation ? Rich options for interconnecting apps across network boundaries Reliable, transaction-aware cloud messaging infrastructure for business apps. Consistent, modeling-friendly management surface and service virtualization capabilities Rich, declarative content-based routing, document transformation, and process coordination.
Inventory and Fulfillment Centers ? Retail Points of Sale Real Time Retail Analytics Business Operations and Marketing
Service Bus Store Inventory Queue
Store Service Bus Store Inventory Queue Store Load Leveling Store
Store Service Bus Store Inventory Queue Store Inventory Load Balancing Store
Audit Service Bus Sub Store Inventory Data Collection Topic Sub Audit Taps
Audit Service Bus Sub Store Inventory Data Collection Topic Sub Sub Dashboard Real-Time Observation
Audit Service Bus Sub Store Inventory Data Collection Topic Sub Sub Sub MartVue Analyzer Analysis Topic Dashboard Sub Real-Time Analysis
Audit Service Bus Sub Store Inventory Data Collection Topic Sub Sub Sub MartVue Analyzer Analysis Topic Dashboard Sub Catalog Topic Sub Scale-Out Eventing
Queues! • Reliable, durable storage – up to 1GB per Queue* • Queues stay in the system once created, no TTL limit • Max message size 256KB, Sessions allow grouping • Messaging API, WCF, and HTTP/REST Interfaces P Queue C • *Limited to 100MB per Queue for CTP
Why Queues? P Queue C Load Leveling Flatten spiky traffic into a predictable stream of work
Why Queues? C P Queue C C Load Balancing C • Balance Work Across a Pool of Workers • Add and Remove Workers Based on Need (Queue Length)
Why Queues? P Queue C Temporal Decoupling • Publish Work To Workers That Are Temporarily Offline • Enable Scheduled Batch Processing
Why Queues? P Queue C Integrity • Don’t Lose Work If Errors Occur Before Processing Completes • Peek/Lock plus De-Dupe can often replace full Tx semantics
Balancing Work With Queues ASP.NET Frontend Reply Queue Worker ASP.NET Frontend Reply Queue Worker ASP.NET Frontend Reply Queue Worker ASP.NET Frontend Reply Queue Worker ASP.NET Frontend Work Queue Worker • Can’t Stress Out The Backend • Frontend queries by correlation ID with timeout • Notifies user if timeout passes without response
Topics! S C • All the Features of Queues + Publish/Subscribe • Up to 2000 Subscriptions on a Topic • Each Subscription is a virtual queue getting message copies • Subscriptions can have filters and actions P Topic S C S C
Rules and Filters Subscription • Rules: • Rules select messages based on conditions • More than one rule for a subscription • Each matching rule yields copy of a message • Filter Conditions and Actions: • Condition represented by expressions • Actions can modify msg props during retrieval Rule Condition Action Rule Condition Action
Filter Expressions Filter conditions operate on message properties and are expressed in SQL’92 syntax • InvoiceTotal > 10000.00 OR ClientRating <3 • ShipDestCtry = ‘USA’ AND ShipDestState=‘WA’ • LastNameLIKE ‘V%’ Filters actions may modify/add/remove properties as message is selected SET AuditRequired = 1
Why Topics? C S C P Topic S C S C Event Fan Out C • Publish Events To Many Subscribers • Subscription Can Be Shared By Competing Consumers
Why Topics? C P Topic S C S C Tap C • Primary Subscription Used Like a Queue • Secondary Subscription Used As Audit Tap
Why Topics? C 0 < x < 33 S C P Topic S C 34 < x < 66 S C Partitioning 67 < x < 100 C • Filters applied to distribute messages to partitions • Mutually exclusive filters covering ranges
Creating Things on The Namespace ServiceBusNamespaceClientnamespaceClient = newServiceBusNamespaceClient(baseAddress, TransportClientCredentialBase.CreateSharedSecretCredential(acc, key)); // Create a queue with default settings namespaceClient.CreateQueue("DefaultQueue"); // Create a queue with custom settings QueueDescriptionqd = newQueueDescription(); qd.DefaultMessageTimeToLive= newTimeSpan(1, 0, 0); qd.EnableDeadLetteringOnMessageExpiration= true; namespaceClient.CreateQueue("CustomQueue", qd); // Delete entities namespaceClient.DeleteQueue("DefaultQueue");
The Service Bus Namespace Client • Management operations are performed using the ServiceBusNamespaceClient • CreateTopic, GetTopic, DeleteTopic • CreateQueue, GetQueue, DeleteQueue • Yields Queue and Topic instances • Provide access to metadata and settings • Takes QueueDescription and TopicDescription instances • Inputs for CreateTopic/Queue ServiceBusNamespaceClient clemens.servicebus.appfabriclabs.com / create delete Q T
Runtime API Choices Apps HTTPREST SOAP WS-*(Relay Clients) WCF Service Model Messaging API WCF Bindings Service Bus Relay Protocol Implementation(private) .NET Framework 4.0 Any Platform Service Bus
The Messaging API Messaging-Specific API That Provides Access To All Features HTTPREST SOAP WS-*(Relay Clients) WCF Service Model Messaging API WCF Bindings Service Bus Relay Protocol Implementation(private) .NET Framework 4.0 Any Platform
MessagingFactory MessagingFactory Connection Manager (private) • Clients for sending/receiving messages are created via MessagingFactory • Factory creates entity-specific “client” • QueueClient, TopicClient, SubscriptionClient • Clients create send and receive objects • MessageSender, MessageReceiver, SessionReceiver • Provides an abstraction that allows client send/receive code to be written to Queues, Topics, and Subscription in an identical fashion. QueueClient SubscriptionClient TopicClient MessageSender MessageReceiver SessionReceiver
Sending Messages // Send a message with system and application properties set BrokeredMessagebm = BrokeredMessage.CreateMessage(); bm.Label = "PurchaseOrder123"; bm.TimeToLive = newTimeSpan(0, 5, 0); bm.Properties["PurchaseOrderID"] = 1234; ms.Send(bm); MessagingFactoryfactory = MessagingFactory. Create(baseAddress, factorySettings); QueueClientqueueClient = factory.CreateQueueClient("DefaultQueue"); // Create a MessageSender MessageSenderms = queueClient.CreateSender(); // Send a message with a String body ms.Send(BrokeredMessage.CreateMessage("Test message"));
Receiving Messages // Create a MessageReceiver with PeekLock semantics MessageReceiver mr2 = queueClient.CreateReceiver(ReceiveMode.PeekLock); BrokeredMessage rm2 M= mr.Receive(); try { // ProcessMessage(rm2); rm2.Complete(); } catch (Exception e) { rm2.Abandon(); } // Create a MessageReceiver with ReceiveAndDeletesemantics MessageReceivermr = queueClient.CreateReceiver(ReceiveMode.ReceiveAndDelete); BrokeredMessagerm = mr.Receive();
Sessions // Create a SessionReceiver to get next available session SessionReceiversr = queueClient.AcceptSessionReceiver(ReceiveMode.PeekLock); BrokeredMessagerm3 = sr.Receive(); try { ProcessMessage(rm3); sr.Session.SetState(bytes); rm3.Complete(); } catch(Exception) { rm3.Abandon(); }
Topic MessagingFactoryfactory = MessagingFactory.Create(baseAddress, factorySettings); // Create a TopicClient TopicClienttopicClient = factory.CreateTopicClient("DefaultTopic"); // Create a MessageSender MessageSenderms = topicClient.CreateSender(); // Send a message with a String body ms.Send(BrokeredMessage.CreateMessage("Test message")); // Create a SubscriptionClient SubscriptionClientsubscriptionClient=factory.CreateSubscriptionClient("DefaultTopic/MySubscription"); // Create a MessageReceiver MessageReceivermr = subscriptionClient.CreateReceiver(ReceiveMode.ReceiveAndDelete); BrokeredMessagerm = mr.Receive();
Subscription Filter Rules // Create a topic and 3 subscriptions. Topic topic = namespaceClient.CreateTopic(Program.TopicName); // Create a subscription for all messages sent to topic. topic.AddSubscription(SubsNameAllMessages, newMatchAllFilterExpression()); // Create a subscription that'll receive all messages with // color property with value "blue" and brushSize with value 10. stringfilterExpression = "color = 'blue' AND brushSize = 10"; topic.AddSubscription(SubsNameFilteredMessages, newSqlFilterExpression("color = 'blue' AND brushSize = 10")); // Create a subscription that'll receive all messages which have CorrelationId set to foo topic.AddSubscription(SubsNameCorrelatedMessages, newCorrelationFilterExpression("foo"));
Subscription Filter Actions //Create a topic myTopic= namespaceClient.CreateTopic("IssueTrackingTopic"); // Create a Rule that stamps Importance property value 'Low' RuleDescriptiondefaultPriRuleDescription= newRuleDescription(); defaultPriRuleDescription.FilterAction= newSqlFilterAction("set Importance = 'Low';"); // Create a Rule that selectively stamps Priority and Importance values RuleDescriptionhighPriRuleDescription= newRuleDescription(); highPriRuleDescription.FilterExpression = newSqlFilterExpression("SupportPackage = 'Premium' OR Severity <= 1"); highPriRuleDescription.FilterAction= newSqlFilterAction("set Priority = 1;set Importance = 'High';"); // Create a Subscription and apply rules SubscriptionmySub= myTopic.AddSubscription("IssueTrackingSubscription", defaultPriRuleDescription); mySub.AddRule("High Priority", highPriorityRuleDescription);
WCF ServiceBusMessagingBinding Convenient, Familiar Experience For Many Apps HTTPREST SOAP WS-*(Relay Clients) WCF Service Model Messaging API WCF Bindings Service Bus Relay Protocol Implementation(private) .NET Framework 4.0 Any Platform
WCF Experience • ServiceBusMessagingBinding • One-Way Messaging • Automatic Pump – Pull/Push Translation • IInputChannel, IOutputChannel, IInputSessionChannel • Transport-Level Security • ServiceBusMessagingFactorySettings available for tweaking as binding properties • BrokeredMessage available as a message property of the WCF message on receive Application / Dispatcher Service Bus Transport Channel .Net API SOAP over SBMP
Summary • AppFabric is the New Middle-Tier • Building Blocks for Building Real Apps • Service Bus is the enabler for ‘hybrid apps’ • Connectivity and Reliable Messaging • Very rich new Publish/Subscribe Capabilities • CTP Available Now
Required Slide Speakers, please list the Breakout Sessions, Interactive Discussions, Labs, Demo Stations and Certification Exam that relate to your session. Also indicate when they can find you staffing in the TLC. Related Content • COS311 - Introduction to Windows Azure AppFabric Composite Applications • MID271-INT - Futures: Integration Capabilities in Windows AppFabricMID373-INT - Accessing Enterprise Data from the Cloud and Mobile Devices Using Microsoft BizTalk Server and Windows Azure AppFabric
Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Track Resources • http://www.microsoft.com/windowsazure/appfabric/overview/ • https://portal.appfabriclabs.com