Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Azure Service Bus -
Taming the Beast
Azure Service Bus –
Taming the Beast
Sean Feldman / @sfeldman
Is it a beast at all?!
ASB for Queueing
Sender ReceiverTemporal
couplingqueue
ASB for Messaging
Building Blocks
• Remote Service
• Entities
• Queues
• Topics
• Subscriptions
• Rules
• Client (WindowsAzure.ServiceBus)
Brokered Messages
Headers
Body
256 KB (Standard)
1 MB (Premium)
64 KB
• Requires a client
• A client to send
• A client to receive
Sending/Receiving Messages
Sending and Receiving
QueueClient
TopicClient
MessageSender
QueueClient
SubscriptionClient
MessageReceiver
• MessageSender...
Receive Modes
ReceiveAndDelete
Broker
Consumer
A
Consumer
B
PeekLock
• PeekLock is at-least-once delivery
• ReceiveAndDele...
PeekLock-ed Options
Receive
Complete Abandon Defer Deadletter
Lock timeout
expired X
MaxDeliveryCount
Message marked
as co...
Receiving with Message Pump
Complete
Abandon
Defer
Deadletter
• OnMessage API to implement message pump
• OnMessageOptions...
Duplicate Detection
{
"_id": "592dede7e37e197bc434cf0b",
"index": 0,
"isActive": false
}
Broker
{
"_id": "592dede7e37e197b...
Auto-Forwarding
queue1 queue2
Namespace
Multiple Forwardings
• Forwarding is native on broker
• Maximum 3 hops
Dead-Lettering
• Dead-lettering happens for a reason, DeadLetterReason
• Forwarded DLQed messages have a source, DeadLette...
Message Expiration
• Good for time sensitive messages
• Messages are cleared when a client connects
Ephemeral (Idle) Entities
• Minimum 5 minutes
• Messages will be gone
Scheduling
• Scheduling messages for future
• Up to years (TimeSpan.Max)*
Batching
Destination A
• Atomic operation
• Single destination
• 100 or less messages
• Total size is limited
Transactions - Atomic Sends
Transaction
Destination A
• Messages can be sent one at a time
• Transaction scope to complete...
Transactions - Atomic Sends with Receive
Transaction
Destination A
Destination B
Destination C
Source
• Incoming and outgo...
There’s more to queues than meets the eye
• queue/$DeadLetterQueue
• queue/$Transfer
• queue/$Transfer/$DeadLetterQueue• N...
Pub/Sub
Topic: mytopic
Subscription: mysub1
Rules
HighPriority
NormalPriority
Filter
Action
Filter
Action
sys.Label LIKE ‘...
Multiple rules
Topic: mytopic
Subscription: mysub
Rules
Rule1
Filter
Action
sys.Label LIKE '%rush%'
Rule2
Filter
Action
Am...
FIFO
Multiplexing And Order Preservation
#2 #3 #2 #1 #1
Consumer A
Consumer B
Session 1
Session 2
• Ordered processing is ...
Challenge
If a single factory produces a connection, how many connections
can it create?
A) Many
B) One
C) Defined Maximum...
• RetryPolicy
• exception.IsTransient
Exception Handling
• Default RetryPolicy is great
• Handle transient exceptions
• Un...
What about .NET Core?
• Microsoft.Azure.ServiceBus
• Full Framework, .NET Standard 1.3, and UWP support
• Rapidly catching...
Thank you
Sean Feldman, Solutions Architect @ Particular Software
@sfeldman
http://weblogs.asp.net/sfeldman
Upcoming SlideShare
Loading in …5
×

Azure Service Bus - Taming the Beast

345 views

Published on

Azure Service Bus features and advanced usage

Published in: Software
  • Be the first to comment

  • Be the first to like this

Azure Service Bus - Taming the Beast

  1. 1. Azure Service Bus - Taming the Beast
  2. 2. Azure Service Bus – Taming the Beast Sean Feldman / @sfeldman
  3. 3. Is it a beast at all?!
  4. 4. ASB for Queueing Sender ReceiverTemporal couplingqueue
  5. 5. ASB for Messaging
  6. 6. Building Blocks • Remote Service • Entities • Queues • Topics • Subscriptions • Rules • Client (WindowsAzure.ServiceBus)
  7. 7. Brokered Messages Headers Body 256 KB (Standard) 1 MB (Premium) 64 KB
  8. 8. • Requires a client • A client to send • A client to receive Sending/Receiving Messages
  9. 9. Sending and Receiving QueueClient TopicClient MessageSender QueueClient SubscriptionClient MessageReceiver • MessageSender and MessageReceiver for code that doesn’t care about entity type
  10. 10. Receive Modes ReceiveAndDelete Broker Consumer A Consumer B PeekLock • PeekLock is at-least-once delivery • ReceiveAndDelete is at-most-once delivery • Use ReceiveAndDelete with caution • Consumers are competing
  11. 11. PeekLock-ed Options Receive Complete Abandon Defer Deadletter Lock timeout expired X MaxDeliveryCount Message marked as completed and removed from the queue. Message becomes visible on the queue and can be received again. Message remains on the queue and can be received later using SequenceNumber Message is moved to deadletter sub- queue and can be received from that queue. Message is moved to deadletter sub- queue and can be received from that queue. • Abandon is not Defer • Deferred messages can only be retrieved by their SequenceNumber • Message can be dead-lettered explicitly
  12. 12. Receiving with Message Pump Complete Abandon Defer Deadletter • OnMessage API to implement message pump • OnMessageOptions for parallelism, lock extension, and completion • OnMessageOptions.ExceptionReceived
  13. 13. Duplicate Detection { "_id": "592dede7e37e197bc434cf0b", "index": 0, "isActive": false } Broker { "_id": "592dede7e37e197bc434cf0b", "index": 0, "isActive": false } • Deduplication on message ID only • Deduplication time period specified per entity • Time based. Idempotency on consumers might be a better option
  14. 14. Auto-Forwarding queue1 queue2 Namespace
  15. 15. Multiple Forwardings • Forwarding is native on broker • Maximum 3 hops
  16. 16. Dead-Lettering • Dead-lettering happens for a reason, DeadLetterReason • Forwarded DLQed messages have a source, DeadLetterSource • 117051215727656
  17. 17. Message Expiration • Good for time sensitive messages • Messages are cleared when a client connects
  18. 18. Ephemeral (Idle) Entities • Minimum 5 minutes • Messages will be gone
  19. 19. Scheduling • Scheduling messages for future • Up to years (TimeSpan.Max)*
  20. 20. Batching Destination A • Atomic operation • Single destination • 100 or less messages • Total size is limited
  21. 21. Transactions - Atomic Sends Transaction Destination A • Messages can be sent one at a time • Transaction scope to complete or abort • Single destination • 100 or less messages • Total size is limited
  22. 22. Transactions - Atomic Sends with Receive Transaction Destination A Destination B Destination C Source • Incoming and outgoing messages participate in transaction • Multiple outgoing destinations • Single namespace • Possible “ghost” messages • AMQP not supported*
  23. 23. There’s more to queues than meets the eye • queue/$DeadLetterQueue • queue/$Transfer • queue/$Transfer/$DeadLetterQueue• Non-delivered message was not lost • Transaction doesn’t fail • Another DLQ to monitor
  24. 24. Pub/Sub Topic: mytopic Subscription: mysub1 Rules HighPriority NormalPriority Filter Action Filter Action sys.Label LIKE ‘%rush%’ OR Amount >= 100 (Amount < 100) AND (sys.Label NOT LIKE '%rush%') SET Priority=‘high’ SET Priority=‘normal’ Subscription: mysub1 Rules • Broadcasting w/o knowing the recipients • Message headers can be mutated • Enables different levels of processing
  25. 25. Multiple rules Topic: mytopic Subscription: mysub Rules Rule1 Filter Action sys.Label LIKE '%rush%' Rule2 Filter Action Amount >= 100 • Rules evaluated using OR logic • When headers mutated, duplicates created
  26. 26. FIFO Multiplexing And Order Preservation #2 #3 #2 #1 #1 Consumer A Consumer B Session 1 Session 2 • Ordered processing is guaranteed • Max concurrency is 1 • Single consumer only
  27. 27. Challenge If a single factory produces a connection, how many connections can it create? A) Many B) One C) Defined Maximum D) None above • Factory is a connection • Factory per client for high throughput • Factories are not cheap
  28. 28. • RetryPolicy • exception.IsTransient Exception Handling • Default RetryPolicy is great • Handle transient exceptions • Unless it’s a TimeoutException during lock renewal
  29. 29. What about .NET Core? • Microsoft.Azure.ServiceBus • Full Framework, .NET Standard 1.3, and UWP support • Rapidly catching up with the current client • Support plugins • OSS • Use if don’t need advanced features • No management operations, use separate package • AMQP only*
  30. 30. Thank you Sean Feldman, Solutions Architect @ Particular Software @sfeldman http://weblogs.asp.net/sfeldman

×