SlideShare a Scribd company logo
Yves Goeleven & Sean Feldman
Solution Architects & Azure MVPs
http://particular.net
Azure Service Bus
Setting up communication across boundaries
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Secure & reliable communication
between software components
across network boundaries.
• Inside cloud services
• Between datacenters
• Between branch offices
• Hybrid solutions
• IoT & Mobile devices
When do you need Azure Service Bus ?

 
Introduction to ServiceInsight for NServiceBusAzure Service Bus
• DNS (mynamespace.servicebus.windows.net): Scale Unit allocation
• Load Balancer: High Availability
• Gateway Node: Authorization & entity lookup
• Broker Node: Servicing entity operations store
• Store: SQL Azure Database or Storage Container
High Level Architecture Overview
Scale Unit
Scale Unit
DNS
L
B
L
B
Gateway
Gateway
Gateway
Gateway
Client
Broker
Broker
Broker
Broker
Store Store Store
Store
Store Store
StoreStore Store
Store
Store
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Entity: a generic term for constructs in an Azure Service Bus namespace
Entity ?
Queue
Subscription
Subscription
Topic
Sending
Client
Sending
Client
Receiving
Client
Receiving
Client
Receiving
Client
Receiving
Client
Each entity is a SQL Azure Database or
Storage Blob under the hood!
Messaging Entities
• Queue
• Topic
• Subscription
• Rule
Other (out of scope): Relay,
EventHub, Consumer Group, ...
Connectivity
Introduction to ServiceInsight for NServiceBusAzure Service Bus
2 Ways to connect
• NamespaceManager: to create & manage entities
• MessagingFactory: to send/receive
Connectivity
Introduction to ServiceInsight for NServiceBusAzure Service Bus
NamespaceManager
• Namespace Address
• TokenProvider
• Methods:
• Get, Exists, Create,
Update, Delete
Connecting to manage entities
Namespace
Manager
Additional options
• REST API: https://docs.microsoft.com/en-us/rest/api/servicebus/
• ARM: https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-resource-manager-
overview
Token
Provider
REST API
HTTPS
Creation is really expensive!
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Exceptions to deal with:
Connectivity
• Timeouts
• Authorization (manage)
Broker Exceptions
• Transient
• Non-transient
Concurrency conflicts
What can possibly go wrong?
DNS
L
B
Gateway
Client
Broker
 timeout
 timeout
 Exception  Exception
 Unauthorized
Client
? Concurrency conflict
 timeout
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
MessagingFactory
• Namespace Address
• TokenProvider
• Connection Settings
• Maintains the network
connection
MessageSender/Receiver
• Created by Factory
• Logical connection
Connecting to send/receive messages
Messaging
Factory
Message
Sender
Establishing a physical connection is expensive!
Message
Receiver TCP/WebSocket
Connection
AMQP/SBMP
Messaging
Factory
Message
Sender
Message
Receiver TCP/WebSocket
Connection
AMQP/SBMP
Broker
Gateway
Node
Broker
Gateway
Node
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
You want to receive/send as long as
your application lives.
Physical connection will drop!
Creating a factory every time is not
an option: establishing connection is
expensive!
Lifecycle management
• Maintain instances/pools
• Manage connection & open new if
closed
Additional Connectivity Challenges
DNS
L
B
Gateway
Factory  Local interruption
 Hardware failures
 Reboot
Factory
C#
Reliable Message Exchange:
Receiving
Introduction to ServiceInsight for NServiceBusAzure Service Bus
2 Ways to receive and process
messages
• Receive And Delete
• Peek Lock
Receiving messages
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Message deleted upon receive.
Cannot rollback received
message.
Single shot processing
• Exception occurs = message
lost!
Cloud environment is very
susceptible to exceptions!
• Advise against this mode for
workflow style processing
Receive and Delete
Message
Receiver
Receive And Delete
 Delete
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Hide message on receive
• Temporal lock
• Explicit complete/abandon
after processing
Multi shot processing
• Exception occurs = Retry
• Retry counter
• Counter exceeded => DLQ
Slow processing = retries!!!
• RenewLock -> more gotcha’s
there, see performance section
Peek Lock
Message
Receiver
Peek Lock
DLQ
Temporal Lock
 Delete
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
What Topology to use?
• Queue per message type
• Queue per receiver
Serialization Challenges
• Internal serialization or not?
• Need to deserialize same way!
• What CLR Type (Q per endpoint)
Concurrency Challenges
• All code must be thread safe
Handling Multiple Message Types
Receiver
Receiver
Sender
ReceiverSender
Is this the right way to construct a message?
new BrokeredMessage(“{json}”)
Sender
Receiver
Receiver
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
MaxDeliveryCount
• To avoid locking on processing
problematic messages, a
message is automatically
deadlettered after number of
deliveries.
Challenges
• Poisonous vs errored messages
• Building a backing off strategy for
retries (3rd party web service)
• Monitoring for DLQed messages
over multiple entities
Dead Letter Queue vs Business Errors
DLQ
Max
Delivery
Count
 failed processing
Receiving
Client
10
.
.
.

 failed processing
Receiving
Client
2

 failed processing
Receiving
Client
1
C#
Reliable Message Exchange:
Sending
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Challenges we’ll cover
• Throttling
• Message size
• Flooding entities
• Transactions
Sending messages
Introduction to ServiceInsight for NServiceBusPresentation title
Usage exceeding quotas, the
broker will throw a
ServerBusyException.
Mitigation: retry after 10 seconds.
Retries can fail as well.
Can’t retry the same message
object.
Exception Handling (User Code)
 succeeded
Sending
Client
.
.
.

 throttled
Sending
Client

 throttled
Sending
Client
Operations can and will fail. Based on exception, need to be retried.
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Message size (including headers)
• Standard tier: 256KB
• Premium tier: 1MB
Headers: up to 64KB
MessageSizeExceededExceptio
n
Message Size
Sending
Client

Size < MAX
Sending
Client

Size > MAX
Warning! Message size is not
known until it’s sent out…
“To get an accurate value for the size of a
BrokeredMessage, you should read the Size
property after completing the Send/Receive
operation on the BrokeredMessage.”
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Scenario:
An orphaned subscription queue
receiving messages that are not
processed.
Challenges
• Overflooding subscriptions
• Overall namespace
performance degradation
Overflooding Subscriptions
Subscription
Subscription
Topic
Sending
Client
Receiving
Client
Receiving
Client
Solutions
• Use Forwarding
Gotcha
• TTL on subscription
Forwarding
Receiving
Client
Sending
Client
Introduction to ServiceInsight for NServiceBusAzure Service Bus
All messages succeed or fail –
atomic
NOT entirely what you think!
• Single queue only
• No other transactional
resources allowed
Transactions
Queue
Sending
Client
Queue A
Sending
Client
Queue B


C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
All messages succeed or fail -
atomic
Surprise!
A hard limit of 100 messages or
TransactionSizeExceededExcep
tion
Prevents usage of batch
completion, has negative
performance impact
Transactions and Number of Messages
Sending
Client
1 100…
Sending
Client
1 100… 101
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
All messages succeed or fail –
atomic
NOT entirely what you think!
• Abandon of incoming message
can not be included!
• Complete can be included
• Single queue only
• If complete included, sends
must go to receive queue
• No other transactional
resources allowed
Transactions with Receive Operations
Queue
Client
Queue A
Client
Queue B


Complete
Complete
Introduction to ServiceInsight for NServiceBusAzure Service Bus
A hidden gem in a heap of
features
Work around for the single queue
transaction limit!
• Uses receive queue as a
transfer queue
Use limited within namespace
Send Via
myQueue
Receiving
Client
queueA
Sending
Client
queueB
atomic operation
f
o
r
w
a
r
d
i
n
g
transfer queue
C#
Performance
Introduction to ServiceInsight for NServiceBusAzure Service Bus
DOs and DONTs
• Factories
• Batching
• Coding practices
• Prefetching
Performance improvements
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Remember
• Using multiple senders
helps.
• More factories helps more.
Multiple Factories
Messaging
Factory
Message
Sender
Message
Sender TCP/Websocket
Connection
AMQP/SBMP
Messaging
Factory
Message
Sender
Message
Sender TCP/Websocket
Connection
AMQP/SBMP
Broker
Gateway
Node
Broker
Gateway
Node
C#
Introduction to ServiceInsight for NServiceBusAzure Service Bus
2 Kinds
• Batch flush interval
• Batched send
Batch size
• Standard tier: 256KB
• Premium tier: 1MB
MessageSizeExceededException
Bonus! Total message size is not
known until it’s sent out…
Extra Bonus! Max 100 messages
when sending inside
transactionscope
Batch Sending
Sending
Client
1 N…
Sending
Client
1 N…
Batch size < MAX
Batch size > MAX
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Don’t!
Do!
Coding Practices That Kill Native Batching
foreach(var message in messages)
{
await sender.SendAsync(message)
}
var tasks = new List<Task>()
foreach(var message in messages)
{
tasks.Add( sender.SendAsync(message) )
}
await Task.WhenAll(tasks)
Introduction to ServiceInsight for NServiceBusAzure Service Bus
How it works
• Load additional messages when
receiving
• Prefetched messages are locked on
the gateway
• Each client maintains its own in-
memory cache of processing
Prefetching
Messaging
Factory
Message
Receiver
Broker
Gateway
Node
C#
Gotchas
• Cannot renew locks
• Prefetch size depends on the processing code speed
• Unlocked prefetched messages are not evicted from cache
• Prefetched messages with expired TTL are not evicted from cache
Introduction to ServiceInsight for NServiceBusAzure Service Bus
Service Bus is a great service!
• With many powerfull
features
Combining those features while
maintaining reliability &
performance is the challenge!
It’s a balancing act

 
Webinar #2
December 14th
Q&A
Thank you

More Related Content

What's hot (20)

PPTX
Message Oriented Architecture using NServiceBus
Lars-Erik Kindblad
 
PDF
Introduction to NServiceBus
Espen Ekvang
 
PDF
Micro on NATS - Microservices with Messaging
Apcera
 
ODP
Art Of Message Queues
Mike Willbanks
 
PPT
Configuring Apache Servers for Better Web Perormance
Spark::red
 
PDF
XMPP Academy #1
Mickaël Rémond
 
PDF
Do More With Message Queue
Hean Hong Leong
 
PDF
Enterprise Messaging with Apache ActiveMQ
elliando dias
 
ZIP
ProcessOne Push Platform: XMPP-based Push Solutions
Mickaël Rémond
 
ODP
The Art of Message Queues - TEKX
Mike Willbanks
 
PPTX
Message queue architecture
Majdee Zoabi
 
PPTX
Beyond REST and RPC: Asynchronous Eventing and Messaging Patterns
Clemens Vasters
 
PDF
Network Latency
Datapath.io
 
PPTX
Scalable Web Architecture and Distributed Systems
hyun soomyung
 
PDF
Devoxx Morocco 2016 - Microservices with Kafka
László-Róbert Albert
 
PDF
Measuring CDN performance and why you're doing it wrong
Fastly
 
PPTX
NATS for Modern Messaging and Microservices
Apcera
 
PPTX
NGINX for Application Delivery & Acceleration
NGINX, Inc.
 
PDF
Messaging With Apache ActiveMQ
Bruce Snyder
 
PPTX
Network latency - measurement and improvement
Matt Willsher
 
Message Oriented Architecture using NServiceBus
Lars-Erik Kindblad
 
Introduction to NServiceBus
Espen Ekvang
 
Micro on NATS - Microservices with Messaging
Apcera
 
Art Of Message Queues
Mike Willbanks
 
Configuring Apache Servers for Better Web Perormance
Spark::red
 
XMPP Academy #1
Mickaël Rémond
 
Do More With Message Queue
Hean Hong Leong
 
Enterprise Messaging with Apache ActiveMQ
elliando dias
 
ProcessOne Push Platform: XMPP-based Push Solutions
Mickaël Rémond
 
The Art of Message Queues - TEKX
Mike Willbanks
 
Message queue architecture
Majdee Zoabi
 
Beyond REST and RPC: Asynchronous Eventing and Messaging Patterns
Clemens Vasters
 
Network Latency
Datapath.io
 
Scalable Web Architecture and Distributed Systems
hyun soomyung
 
Devoxx Morocco 2016 - Microservices with Kafka
László-Róbert Albert
 
Measuring CDN performance and why you're doing it wrong
Fastly
 
NATS for Modern Messaging and Microservices
Apcera
 
NGINX for Application Delivery & Acceleration
NGINX, Inc.
 
Messaging With Apache ActiveMQ
Bruce Snyder
 
Network latency - measurement and improvement
Matt Willsher
 

Viewers also liked (20)

PPTX
Azure Service Bus Overview
BizTalk360
 
PPTX
Azure Service Bus
Josh Lane
 
PDF
W poszukiwaniu procesu doskonałego. Wdrożenie Scruma, Continuous Integrations...
3camp
 
PDF
Enterprise messaging
ColdFusionConference
 
PPTX
Windows Azure Service Bus
Pavel Revenkov
 
PPTX
Introduction to Windows Azure Service Bus Relay Service
Tamir Dresher
 
PPTX
Azure Service Bus for Loosely-Coupled Enterprise Software.
Chase Aucoin
 
PDF
HTTPS bez wymówek
3camp
 
DOCX
Seminar report
archana lisbon
 
PPTX
Azure service bus based on cloud computing
arun Prabha
 
PPTX
Calgary azure dev camp - Service Bus
wearsy
 
PPTX
Microsoft Microservices
Chase Aucoin
 
PPTX
Fog computing paper presentation
omkar parab
 
PPTX
[GAB2016] Workshop - Industrialisez vos expérimentations Azure Machine Learni...
Cellenza
 
PDF
FOGCOMPUTING
Anvesh Kolluri
 
PPTX
Business process modeling and analysis for data warehouse design
Slava Kokaev
 
PPTX
Fog Computing
Pachipulusu Giridhar
 
DOCX
fog computing provide security to the data in cloud
priyanka reddy
 
PDF
Harness the Power of Microsoft Azure
RBA
 
PDF
Azure Machine Learning
Mostafa
 
Azure Service Bus Overview
BizTalk360
 
Azure Service Bus
Josh Lane
 
W poszukiwaniu procesu doskonałego. Wdrożenie Scruma, Continuous Integrations...
3camp
 
Enterprise messaging
ColdFusionConference
 
Windows Azure Service Bus
Pavel Revenkov
 
Introduction to Windows Azure Service Bus Relay Service
Tamir Dresher
 
Azure Service Bus for Loosely-Coupled Enterprise Software.
Chase Aucoin
 
HTTPS bez wymówek
3camp
 
Seminar report
archana lisbon
 
Azure service bus based on cloud computing
arun Prabha
 
Calgary azure dev camp - Service Bus
wearsy
 
Microsoft Microservices
Chase Aucoin
 
Fog computing paper presentation
omkar parab
 
[GAB2016] Workshop - Industrialisez vos expérimentations Azure Machine Learni...
Cellenza
 
FOGCOMPUTING
Anvesh Kolluri
 
Business process modeling and analysis for data warehouse design
Slava Kokaev
 
Fog Computing
Pachipulusu Giridhar
 
fog computing provide security to the data in cloud
priyanka reddy
 
Harness the Power of Microsoft Azure
RBA
 
Azure Machine Learning
Mostafa
 
Ad

Similar to Making communication across boundaries simple with Azure Service Bus (20)

PPTX
Best Features of Azure Service Bus
Daniel Toomey
 
PPTX
Cloud Messaging with NServiceBus and Microsoft Azure
Particular Software
 
PPTX
Intro to Azure Service Bus
George Grammatikos
 
PPTX
Messaging Powered Front Ends
Elton Stoneman
 
PPTX
Designing distributed, scalable and reliable systems using NServiceBus
Mauro Servienti
 
PDF
Windows azure service bus reference
Jose Vergara Veas
 
PDF
Middleware in the cloud platform-v2
Hammad Rajjoub
 
PPTX
Azure Messaging Services #1
Azure Riyadh User Group
 
PPTX
NServiceBus in Azure - A Right Tool for the Web(Job)?
Sean Feldman
 
PPTX
The top integration features you probably didn’t know existed in Service Bus
BizTalk360
 
PPTX
NServiceBus
Rich Helton
 
PPTX
Azure Messaging Services 2
Azure Riyadh User Group
 
PPT
SOA with NServiceBus 20130124
Sean Farmar
 
PPTX
Scaling with Asynchronous Messaging
Elton Stoneman
 
PPTX
AppFx.ServiceBus - Simple Messaging with Windows Azure Service Bus
Michael Stephenson
 
PDF
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
Spiffy
 
PPTX
NServiceBus workshop presentation
Tomas Jansson
 
PPTX
Brokered Messaging in Windows Azure
Neil Mackenzie
 
PPTX
Microservices with Net Core 8 and Net Core 6
FranklinGallardo7
 
PPTX
NSBCon UK nservicebus on Azure by Yves Goeleven
Particular Software
 
Best Features of Azure Service Bus
Daniel Toomey
 
Cloud Messaging with NServiceBus and Microsoft Azure
Particular Software
 
Intro to Azure Service Bus
George Grammatikos
 
Messaging Powered Front Ends
Elton Stoneman
 
Designing distributed, scalable and reliable systems using NServiceBus
Mauro Servienti
 
Windows azure service bus reference
Jose Vergara Veas
 
Middleware in the cloud platform-v2
Hammad Rajjoub
 
Azure Messaging Services #1
Azure Riyadh User Group
 
NServiceBus in Azure - A Right Tool for the Web(Job)?
Sean Feldman
 
The top integration features you probably didn’t know existed in Service Bus
BizTalk360
 
NServiceBus
Rich Helton
 
Azure Messaging Services 2
Azure Riyadh User Group
 
SOA with NServiceBus 20130124
Sean Farmar
 
Scaling with Asynchronous Messaging
Elton Stoneman
 
AppFx.ServiceBus - Simple Messaging with Windows Azure Service Bus
Michael Stephenson
 
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
Spiffy
 
NServiceBus workshop presentation
Tomas Jansson
 
Brokered Messaging in Windows Azure
Neil Mackenzie
 
Microservices with Net Core 8 and Net Core 6
FranklinGallardo7
 
NSBCon UK nservicebus on Azure by Yves Goeleven
Particular Software
 
Ad

More from Particular Software (20)

PDF
Scaling for Success: Lessons from handling peak loads on Azure with NServiceBus
Particular Software
 
PDF
Beyond simple benchmarks—a practical guide to optimizing code
Particular Software
 
PDF
An exception occurred - Please try again
Particular Software
 
PPTX
Tales from the trenches creating complex distributed systems
Particular Software
 
PPTX
Got the time?
Particular Software
 
PPTX
Implementing outbox model-checking first
Particular Software
 
PPTX
Reports from the field azure functions in practice
Particular Software
 
PPTX
Finding your service boundaries - a practical guide
Particular Software
 
PPTX
Decomposing .NET Monoliths with NServiceBus and Docker
Particular Software
 
PDF
DIY Async Message Pump: Lessons from the trenches
Particular Software
 
PDF
Share the insight of ServiceInsight
Particular Software
 
PPTX
How to avoid microservice pitfalls
Particular Software
 
PDF
Connect front end to back end using SignalR and Messaging
Particular Software
 
PDF
Async/Await: NServiceBus v6 API Update
Particular Software
 
PDF
Async/Await: TPL & Message Pumps
Particular Software
 
PDF
Async/Await Best Practices
Particular Software
 
PPTX
Making workflow implementation easy with CQRS
Particular Software
 
PPTX
Cqrs but different
Particular Software
 
PPTX
Asynchronous Messaging with NServiceBus
Particular Software
 
PPTX
Beyond the POC: Adopting NServiceBus
Particular Software
 
Scaling for Success: Lessons from handling peak loads on Azure with NServiceBus
Particular Software
 
Beyond simple benchmarks—a practical guide to optimizing code
Particular Software
 
An exception occurred - Please try again
Particular Software
 
Tales from the trenches creating complex distributed systems
Particular Software
 
Got the time?
Particular Software
 
Implementing outbox model-checking first
Particular Software
 
Reports from the field azure functions in practice
Particular Software
 
Finding your service boundaries - a practical guide
Particular Software
 
Decomposing .NET Monoliths with NServiceBus and Docker
Particular Software
 
DIY Async Message Pump: Lessons from the trenches
Particular Software
 
Share the insight of ServiceInsight
Particular Software
 
How to avoid microservice pitfalls
Particular Software
 
Connect front end to back end using SignalR and Messaging
Particular Software
 
Async/Await: NServiceBus v6 API Update
Particular Software
 
Async/Await: TPL & Message Pumps
Particular Software
 
Async/Await Best Practices
Particular Software
 
Making workflow implementation easy with CQRS
Particular Software
 
Cqrs but different
Particular Software
 
Asynchronous Messaging with NServiceBus
Particular Software
 
Beyond the POC: Adopting NServiceBus
Particular Software
 

Recently uploaded (20)

PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 

Making communication across boundaries simple with Azure Service Bus

  • 1. Yves Goeleven & Sean Feldman Solution Architects & Azure MVPs http://particular.net Azure Service Bus Setting up communication across boundaries
  • 2. Introduction to ServiceInsight for NServiceBusAzure Service Bus Secure & reliable communication between software components across network boundaries. • Inside cloud services • Between datacenters • Between branch offices • Hybrid solutions • IoT & Mobile devices When do you need Azure Service Bus ?   
  • 3. Introduction to ServiceInsight for NServiceBusAzure Service Bus • DNS (mynamespace.servicebus.windows.net): Scale Unit allocation • Load Balancer: High Availability • Gateway Node: Authorization & entity lookup • Broker Node: Servicing entity operations store • Store: SQL Azure Database or Storage Container High Level Architecture Overview Scale Unit Scale Unit DNS L B L B Gateway Gateway Gateway Gateway Client Broker Broker Broker Broker Store Store Store Store Store Store StoreStore Store Store Store
  • 4. Introduction to ServiceInsight for NServiceBusAzure Service Bus Entity: a generic term for constructs in an Azure Service Bus namespace Entity ? Queue Subscription Subscription Topic Sending Client Sending Client Receiving Client Receiving Client Receiving Client Receiving Client Each entity is a SQL Azure Database or Storage Blob under the hood! Messaging Entities • Queue • Topic • Subscription • Rule Other (out of scope): Relay, EventHub, Consumer Group, ...
  • 6. Introduction to ServiceInsight for NServiceBusAzure Service Bus 2 Ways to connect • NamespaceManager: to create & manage entities • MessagingFactory: to send/receive Connectivity
  • 7. Introduction to ServiceInsight for NServiceBusAzure Service Bus NamespaceManager • Namespace Address • TokenProvider • Methods: • Get, Exists, Create, Update, Delete Connecting to manage entities Namespace Manager Additional options • REST API: https://docs.microsoft.com/en-us/rest/api/servicebus/ • ARM: https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-resource-manager- overview Token Provider REST API HTTPS Creation is really expensive! C#
  • 8. Introduction to ServiceInsight for NServiceBusAzure Service Bus Exceptions to deal with: Connectivity • Timeouts • Authorization (manage) Broker Exceptions • Transient • Non-transient Concurrency conflicts What can possibly go wrong? DNS L B Gateway Client Broker  timeout  timeout  Exception  Exception  Unauthorized Client ? Concurrency conflict  timeout C#
  • 9. Introduction to ServiceInsight for NServiceBusAzure Service Bus MessagingFactory • Namespace Address • TokenProvider • Connection Settings • Maintains the network connection MessageSender/Receiver • Created by Factory • Logical connection Connecting to send/receive messages Messaging Factory Message Sender Establishing a physical connection is expensive! Message Receiver TCP/WebSocket Connection AMQP/SBMP Messaging Factory Message Sender Message Receiver TCP/WebSocket Connection AMQP/SBMP Broker Gateway Node Broker Gateway Node C#
  • 10. Introduction to ServiceInsight for NServiceBusAzure Service Bus You want to receive/send as long as your application lives. Physical connection will drop! Creating a factory every time is not an option: establishing connection is expensive! Lifecycle management • Maintain instances/pools • Manage connection & open new if closed Additional Connectivity Challenges DNS L B Gateway Factory  Local interruption  Hardware failures  Reboot Factory C#
  • 12. Introduction to ServiceInsight for NServiceBusAzure Service Bus 2 Ways to receive and process messages • Receive And Delete • Peek Lock Receiving messages
  • 13. Introduction to ServiceInsight for NServiceBusAzure Service Bus Message deleted upon receive. Cannot rollback received message. Single shot processing • Exception occurs = message lost! Cloud environment is very susceptible to exceptions! • Advise against this mode for workflow style processing Receive and Delete Message Receiver Receive And Delete  Delete C#
  • 14. Introduction to ServiceInsight for NServiceBusAzure Service Bus Hide message on receive • Temporal lock • Explicit complete/abandon after processing Multi shot processing • Exception occurs = Retry • Retry counter • Counter exceeded => DLQ Slow processing = retries!!! • RenewLock -> more gotcha’s there, see performance section Peek Lock Message Receiver Peek Lock DLQ Temporal Lock  Delete C#
  • 15. Introduction to ServiceInsight for NServiceBusAzure Service Bus What Topology to use? • Queue per message type • Queue per receiver Serialization Challenges • Internal serialization or not? • Need to deserialize same way! • What CLR Type (Q per endpoint) Concurrency Challenges • All code must be thread safe Handling Multiple Message Types Receiver Receiver Sender ReceiverSender Is this the right way to construct a message? new BrokeredMessage(“{json}”) Sender Receiver Receiver C#
  • 16. Introduction to ServiceInsight for NServiceBusAzure Service Bus MaxDeliveryCount • To avoid locking on processing problematic messages, a message is automatically deadlettered after number of deliveries. Challenges • Poisonous vs errored messages • Building a backing off strategy for retries (3rd party web service) • Monitoring for DLQed messages over multiple entities Dead Letter Queue vs Business Errors DLQ Max Delivery Count  failed processing Receiving Client 10 . . .   failed processing Receiving Client 2   failed processing Receiving Client 1 C#
  • 18. Introduction to ServiceInsight for NServiceBusAzure Service Bus Challenges we’ll cover • Throttling • Message size • Flooding entities • Transactions Sending messages
  • 19. Introduction to ServiceInsight for NServiceBusPresentation title Usage exceeding quotas, the broker will throw a ServerBusyException. Mitigation: retry after 10 seconds. Retries can fail as well. Can’t retry the same message object. Exception Handling (User Code)  succeeded Sending Client . . .   throttled Sending Client   throttled Sending Client Operations can and will fail. Based on exception, need to be retried. C#
  • 20. Introduction to ServiceInsight for NServiceBusAzure Service Bus Message size (including headers) • Standard tier: 256KB • Premium tier: 1MB Headers: up to 64KB MessageSizeExceededExceptio n Message Size Sending Client  Size < MAX Sending Client  Size > MAX Warning! Message size is not known until it’s sent out… “To get an accurate value for the size of a BrokeredMessage, you should read the Size property after completing the Send/Receive operation on the BrokeredMessage.”
  • 21. Introduction to ServiceInsight for NServiceBusAzure Service Bus Scenario: An orphaned subscription queue receiving messages that are not processed. Challenges • Overflooding subscriptions • Overall namespace performance degradation Overflooding Subscriptions Subscription Subscription Topic Sending Client Receiving Client Receiving Client Solutions • Use Forwarding Gotcha • TTL on subscription Forwarding Receiving Client Sending Client
  • 22. Introduction to ServiceInsight for NServiceBusAzure Service Bus All messages succeed or fail – atomic NOT entirely what you think! • Single queue only • No other transactional resources allowed Transactions Queue Sending Client Queue A Sending Client Queue B   C#
  • 23. Introduction to ServiceInsight for NServiceBusAzure Service Bus All messages succeed or fail - atomic Surprise! A hard limit of 100 messages or TransactionSizeExceededExcep tion Prevents usage of batch completion, has negative performance impact Transactions and Number of Messages Sending Client 1 100… Sending Client 1 100… 101 C#
  • 24. Introduction to ServiceInsight for NServiceBusAzure Service Bus All messages succeed or fail – atomic NOT entirely what you think! • Abandon of incoming message can not be included! • Complete can be included • Single queue only • If complete included, sends must go to receive queue • No other transactional resources allowed Transactions with Receive Operations Queue Client Queue A Client Queue B   Complete Complete
  • 25. Introduction to ServiceInsight for NServiceBusAzure Service Bus A hidden gem in a heap of features Work around for the single queue transaction limit! • Uses receive queue as a transfer queue Use limited within namespace Send Via myQueue Receiving Client queueA Sending Client queueB atomic operation f o r w a r d i n g transfer queue C#
  • 27. Introduction to ServiceInsight for NServiceBusAzure Service Bus DOs and DONTs • Factories • Batching • Coding practices • Prefetching Performance improvements
  • 28. Introduction to ServiceInsight for NServiceBusAzure Service Bus Remember • Using multiple senders helps. • More factories helps more. Multiple Factories Messaging Factory Message Sender Message Sender TCP/Websocket Connection AMQP/SBMP Messaging Factory Message Sender Message Sender TCP/Websocket Connection AMQP/SBMP Broker Gateway Node Broker Gateway Node C#
  • 29. Introduction to ServiceInsight for NServiceBusAzure Service Bus 2 Kinds • Batch flush interval • Batched send Batch size • Standard tier: 256KB • Premium tier: 1MB MessageSizeExceededException Bonus! Total message size is not known until it’s sent out… Extra Bonus! Max 100 messages when sending inside transactionscope Batch Sending Sending Client 1 N… Sending Client 1 N… Batch size < MAX Batch size > MAX
  • 30. Introduction to ServiceInsight for NServiceBusAzure Service Bus Don’t! Do! Coding Practices That Kill Native Batching foreach(var message in messages) { await sender.SendAsync(message) } var tasks = new List<Task>() foreach(var message in messages) { tasks.Add( sender.SendAsync(message) ) } await Task.WhenAll(tasks)
  • 31. Introduction to ServiceInsight for NServiceBusAzure Service Bus How it works • Load additional messages when receiving • Prefetched messages are locked on the gateway • Each client maintains its own in- memory cache of processing Prefetching Messaging Factory Message Receiver Broker Gateway Node C# Gotchas • Cannot renew locks • Prefetch size depends on the processing code speed • Unlocked prefetched messages are not evicted from cache • Prefetched messages with expired TTL are not evicted from cache
  • 32. Introduction to ServiceInsight for NServiceBusAzure Service Bus Service Bus is a great service! • With many powerfull features Combining those features while maintaining reliability & performance is the challenge! It’s a balancing act   
  • 34. Q&A