MID312 The Cloud. All Apps Move To The Cloud. No They Don’t.
Download
Report
Transcript MID312 The Cloud. All Apps Move To The Cloud. No They Don’t.
MID312
The Cloud.
All Apps Move To The Cloud.
No They Don’t.
Integrated Enterprise
Campaig
n
Loyalty
Travel
Vendor
Market
Health
CRM
LOB
ERP
HR
BI
Shop
BI Portal
Benefits
Time
Card
Very Few Go ‘All In’ On The Cloud.
Firewall
?
Sourced
Vendor
Market
?
NAT
Security Realm
Campaig
n
Loyalty
Travel
Health
CRM
LOB
ERP
HR
BI
Shop
BI Portal
Benefits
Time
Card
So How Can This Work?
Firewall
?
Sourced
Vendor
Market
?
NAT
Security Realm
Loyalty
•
•
•
•
Travel
Existing Web Service Endpoint.
Campaig
No Mutual Trust Between
CRM Systems,
LOB
n
VPN not an option.
Sits Behind Firewall and NAT.
Not built for non-corporate identity
access control
BI
Shop
Health
ERP
HR
BI Portal
Benefits
Time
Card
More Scenarios
Connectivity Relay
Service Bus
Frontend
Nodes
Ctrl
2
NLB
3
Ctrl
1
Sender
Forwarder
4
Receiver
Connectivity Relay
Frontend
Nodes
•
•
•
•
•
•
Service Bus
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
So Far So Good.
(“I’ve seen that already! What’s New?”)
… 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
Rich options for
interconnecting
apps across
network
boundaries
Reliable,
transaction-aware
cloud messaging
infrastructure for
business apps.
Service
Management
Naming,
Discovery
Monitoring
Consistent,
modeling-friendly
management
surface and
service
virtualization
capabilities
Integration
Routing
Coordination
Transformation
Rich, declarative
content-based
routing, document
transformation,
and process
coordination.
Retail Points
of Sale
Real Time
Retail Analytics
?
Inventory and
Fulfillment
Centers
Business
Operations and
Marketing
Service Bus
Store
Queue
Inventory
Store
Service Bus
Store
Queue
Store
Store
Load Leveling
Inventory
Store
Service Bus
Store
Queue
Inventory
Store
Store
Load Balancing
Inventory
Audit
Service Bus
Store
Data Collection
Topic
Audit Taps
Sub
Sub
Inventory
Audit
Service Bus
Store
Data Collection
Topic
Sub
Sub
Inventory
Sub
Dashboard
Real-Time Observation
Audit
Service Bus
Data Collection
Topic
Store
Sub
MartVue
Analyzer
Analysis Topic
Real-Time Analysis
Sub
Sub
Inventory
Sub
Sub
Dashboar
d
Audit
Service Bus
Data Collection
Topic
Store
Scale-Out Eventing
Analysis Topic
Sub
Sub
Inventory
Sub
Sub
MartVue
Analyzer
Sub
Sub
Catalog Topic
Dashboard
Queues!
P
•
•
•
•
Queue
C
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
*Limited to 100MB per Queue for CTP
Why Queues?
P
Queue
Load Leveling
Flatten spiky traffic into a predictable stream of work
C
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
ASP.NET
Frontend
Reply Queue
ASP.NET
Frontend
Reply Queue
Worker
ASP.NET
Frontend
Work Queue
Worker
Worker
Worker
• Can’t Stress Out The Backend
• Frontend queries by correlation ID with timeout
• Notifies user if timeout passes without response
Topics!
P
•
•
•
•
Topic
S
C
S
C
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
Rules and Filters
• 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
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’
• LastName LIKE ‘V%’
Filters actions may modify/add/remove properties as
message is selected
SET AuditRequired = 1
Why Topics?
P
Topic
C
S
C
S
C
S
C
Event Fan Out
• Publish Events To Many Subscribers
• Subscription Can Be Shared By Competing
Consumers
C
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?
P
Topic
Partitioning
0 < x < 33
C
S
C
34 < x < 66 S
C
S
C
67 < x < 100
C
• Filters applied to distribute messages to partitions
• Mutually exclusive filters covering ranges
“Ok, I Get It”
Code? Code!
Creating Things on The Namespace
ServiceBusNamespaceClient namespaceClient =
new ServiceBusNamespaceClient(baseAddress,
TransportClientCredentialBase.CreateSharedSecretCredential(acc, key));
// Create a queue with default settings
namespaceClient.CreateQueue("DefaultQueue");
// Create a queue with custom settings
QueueDescription qd = new QueueDescription();
qd.DefaultMessageTimeToLive = new TimeSpan(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
ServiceBusNamespaceClient
clemens.servicebus.appfabriclabs.com
– CreateTopic, GetTopic, DeleteTopic
/
– CreateQueue, GetQueue, DeleteQueue
•
Yields Queue and Topic instances
create
delete
– Provide access to metadata and settings
•
Takes QueueDescription and
TopicDescription instances
Q
T
– Inputs for CreateTopic/Queue
36
Runtime API Choices
Apps
WCF Service Model
WCF Bindings
Service Bus Relay Protocol
Implementation
(private)
HTTP
REST
SOAP
WS-*
(Relay Clients)
Messaging API
.NET Framework 4.0
Service Bus
Any Platform
The Messaging API
WCF Service Model
WCF Bindings
Service Bus Relay Protocol
Implementation
(private)
HTTP
REST
SOAP
WS-*
(Relay Clients)
Messaging API
.NET Framework 4.0
Any Platform
Messaging-Specific API That Provides Access To All Features
MessagingFactory
•
•
Clients for sending/receiving messages
are created via MessagingFactory
Factory creates entity-specific “client”
– QueueClient, TopicClient,
SubscriptionClient
•
MessagingFactory
Connection Manager (private)
QueueClient
SubscriptionClient
TopicClient
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.
MessageSender
MessageReceiver
SessionReceiver
39
Sending Messages
MessagingFactory factory = MessagingFactory.
Create(baseAddress, factorySettings);
QueueClient queueClient = factory.CreateQueueClient("DefaultQueue");
// Create a MessageSender
MessageSender ms = queueClient.CreateSender();
// Send a message with a String body
ms.Send(BrokeredMessage.CreateMessage("Test message"));
// Send a message with system and application properties set
BrokeredMessage bm = BrokeredMessage.CreateMessage();
bm.Label = "PurchaseOrder123";
bm.TimeToLive = new TimeSpan(0, 5, 0);
bm.Properties["PurchaseOrderID"] = 1234;
ms.Send(bm);
40
Receiving Messages
// Create a MessageReceiver with ReceiveAndDelete semantics
MessageReceiver mr = queueClient.CreateReceiver(ReceiveMode.ReceiveAndDelete);
BrokeredMessage rm = mr.Receive();
// 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();
}
41
Sessions
// Create a SessionReceiver to get next available session
SessionReceiver sr = queueClient.AcceptSessionReceiver(ReceiveMode.PeekLock);
BrokeredMessage rm3 = sr.Receive();
try
{
ProcessMessage(rm3);
sr.Session.SetState(bytes);
rm3.Complete();
}
catch (Exception)
{
rm3.Abandon();
}
42
Topic
MessagingFactory factory = MessagingFactory.Create(baseAddress, factorySettings);
// Create a TopicClient
TopicClient topicClient = factory.CreateTopicClient("DefaultTopic");
// Create a MessageSender
MessageSender ms = topicClient.CreateSender();
// Send a message with a String body
ms.Send(BrokeredMessage.CreateMessage("Test message"));
// Create a SubscriptionClient
SubscriptionClient subscriptionClient =
factory.CreateSubscriptionClient("DefaultTopic/MySubscription");
// Create a MessageReceiver
MessageReceiver mr = subscriptionClient.CreateReceiver(ReceiveMode.ReceiveAndDelete);
BrokeredMessage rm = mr.Receive();
43
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, new MatchAllFilterExpression());
// Create a subscription that'll receive all messages with
// color property with value "blue" and brushSize with value 10.
string filterExpression = "color = 'blue' AND brushSize = 10";
topic.AddSubscription(SubsNameFilteredMessages,
new SqlFilterExpression("color = 'blue' AND brushSize = 10"));
// Create a subscription that'll receive all messages which have CorrelationId set to foo
topic.AddSubscription(SubsNameCorrelatedMessages, new CorrelationFilterExpression("foo"));
44
Subscription Filter Actions
//Create a topic
myTopic = namespaceClient.CreateTopic("IssueTrackingTopic");
// Create a Rule that stamps Importance property value 'Low'
RuleDescription defaultPriRuleDescription = new RuleDescription();
defaultPriRuleDescription.FilterAction = new SqlFilterAction("set Importance = 'Low';");
// Create a Rule that selectively stamps Priority and Importance values
RuleDescription highPriRuleDescription = new RuleDescription();
highPriRuleDescription.FilterExpression =
new SqlFilterExpression("SupportPackage = 'Premium' OR Severity <= 1");
highPriRuleDescription.FilterAction =
new SqlFilterAction("set Priority = 1;set Importance = 'High';");
// Create a Subscription and apply rules
Subscription mySub =
myTopic.AddSubscription("IssueTrackingSubscription", defaultPriRuleDescription);
mySub.AddRule("High Priority", highPriorityRuleDescription);
45
WCF ServiceBusMessagingBinding
WCF Service Model
WCF Bindings
Service Bus Relay Protocol
Implementation
(private)
HTTP
REST
SOAP
WS-*
(Relay Clients)
Messaging API
.NET Framework 4.0
Any Platform
Convenient, Familiar Experience For Many Apps
WCF Experience
• ServiceBusMessagingBinding
– One-Way Messaging
– Automatic Pump – Pull/Push Translation
– IInputChannel, IOutputChannel,
IInputSessionChannel
– Transport-Level Security
Application / Dispatcher
Service Bus Transport
Channel
.Net API
SOAP over
SBMP
• ServiceBusMessagingFactorySettings available
for tweaking as binding properties
• BrokeredMessage available as a message
property of the WCF message on receive
47
Windows Azure Platform Training Kit
Windows Server AppFabric Training Kit
BizTalk 2010 Developer Training Kit
AppFabric Team Blog
Windows Azure AppFabric on MSDN
Windows Server AppFabric on MSDN
http://northamerica.msteched.com
www.microsoft.com/teched
www.microsoft.com/learning
http://microsoft.com/technet
http://microsoft.com/msdn