Code Impact Service Bus Presentation – Slides

advertisement
Driving the
Azure Service Bus
Scott Klueppel
Solutions Architect
SOAlutions, Inc.
#jaxcodeimpact
@kloopdogg
Agenda
Azure Service Bus
- 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
Windows Azure
SDK
2.4 Aug2014
Visual Studio
2013
Supported
Visual Studio
2012
Supported
Visual Studio
2010
Not Supported
2.3
Apr2014
Supported
Supported
Not Supported
2.2
Oct2013
Supported
Supported
Not Supported
2.1
Jul2013
Not Supported
Supported
Supported
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?
7
Relays
Relay message (load balancing)
Service Bus
Send
message
Access Control Service
6
5
Client
Remote
8
Return
Token
4
Send
Shared Secret
Return
Token
Deliver message
Open Relay
Connection
3
2
1
Send
Shared Secret
WCF
Service
On-Premise
Client
NAT
Firewall
Corporate
Firewall
NAT
Scenario 1: Network Infrastructure
Relays
On-Premise
Web App
Relay
WCF
Service
Other
Service
Dynamic IPs
No LB/ACE
NAT
Firewall
Corporate
Firewall
NAT
Scenario 2: Emergency Use
Relays
On-Premise
Web App
WCF
Service
Client
Other
Service
Relay
WCF
Service
NAT
Firewall
Firewall
NAT
Scenario 3: Roaming Devices
Corporate .
WCF
Service
Relay
Client
On-Premise
Web App
Client
Coffee Shop
Relays
.
Other
Service
Considerations
Relays
1. If there are no listeners, the service is
unavailable
2. No automatic scaling for high bursts of traffic
3. Load balancing is not configurable
4. 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
- Messages are durably stored until consumed
- Messages pulled from queue by one or more
competing consumers
- Benefits:
- Temporal decoupling
- Load leveling
- Load balancing
Queues
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
Queues
Client
Queue
Service
Client
Topic
Topics (with subscriptions)
Sub {color=red}
Sub {true}
Service
Service
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
1. Poll using “Receive” operations (client API)
2. Use messaging bindings with a WCF service
Using queues
Queues
- Create a queue client
- Send a message
- Receive a message
var
TimeSpan
BrokeredMessage
uri =receiveTimeout
issueMsg==TimeSpan.FromSeconds(5);
new BrokeredMessage(issue);
while
queueClient.Send(issueMsg);
ServiceBusEnvironment.CreateServiceUri("sb",
((message = queueClient.Receive(receiveTimeout))
namespace,
!= null)
String.Empty);
TokenProvider
{
credentials =
//TODO:
TokenProvider.CreateSharedSecretTokenProvider(IssuerName,
Do work
IssuerKey);
message.Complete();
MessagingFactory
}
factory = MessagingFactory.Create(uri, credentials);
QueueClient queueClient = factory.CreateQueueClient("TestQueue");
Using topics
Topics
- Send a message
- Receive a message
MessagingFactory factory = MessagingFactory.Create(uri, credentials);
SubscriptionClient
TopicClient topicClient
subscriptionClient
= factory.CreateTopicClient(topicName);
=
factory.CreateSubscriptionClient(topicName, subscriptionName);
TimeSpan
BrokeredMessage
receiveTimeout
issueMsg==TimeSpan.FromSeconds(5);
new BrokeredMessage(issue);
topicClient.Send(issueMsg);
while ((message = subscriptionClient.Receive(receiveTimeout)) != null)
{
//TODO: Do work
message.Complete();
}
Auto-forwarding
- Auto-forwarding topics and queues
- Improves overall performance
Client
Client
Queue
Subscription
Topic
Client
Subscription
Queue
Subscription
Subscription
Queue
Auto-forwarding
Auto-forwarding
Fan
Scale
inout
from
for(maybe
several
more overall
queues
subscriptions
Forward
to
delayed)
processing queues
Topic
Queue
Subscription
Topic
Topic
Queue
Subscription
Topic
Queue
Subscription
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 of
message processing
- Maximize
performance
- Minimize operational
costs
Cross-Platform
AMQP
Devices
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
Azure Service Bus
- 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)
Use Case: Sensors/Devices
Azure Service Bus
Ingestion / Analysis
Coordinator
ZigBee Radio
Solar Cell(s)
Batteries
Sensors
- Temperature
- Moisture
- Light
- Sound
Event Hubs (Preview)
Azure Service Bus
- 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 Proton
http://qpid.apache.org/proton/
Thank you!
Scott Klueppel
Solutions Architect
SOAlutions, Inc.
#jaxcodeimpact
@kloopdogg
Download