the top integration features you probably didn’t know existed in service bus
TRANSCRIPT
Sponsored & Brought to you by
The top integration features you probably didn’t know existed in Service Bus
Dan Rosanova
https://twitter.com/DanRosanova
https://www.linkedin.com/in/danrosanova
Some history
• Original Service Bus engineering team was (and continues to have been) from BizTalk in the past – the messaging side of BizTalk in particular.
• Same team also maintains MSMQ – still
I knew messaging
I thought I knew Service Bus
Duplicate Detection
• What: Ignore messages that are sent more than once in a specified time window
• When• Upstream applications are unpredictable and noisy• They may send duplicate messages
• Why• Ever seen a website that says 'don't click buy again to avoid multiple charges'
• How: Use a value as MessageId to control this behavior and set the window you need on the queue or topic
• Impact: Idempotent processing -> yes you probably need this
Scheduled Messages
• What: place a message in a queue or topic that doesn’t “appear” until a specified future time
• When• Sender wants to send something now, but doesn't want an action to take
place on it until later
• Take actions to complete or rollback work at a specified point
• Why: Keep your services as simple as possible – we already have it
• How: Set the ScheduledEnqueueTimeUtc on BrokeredMessage
• Impact: Rich temporal control of long running processes
Defer
• What: Mark a message to be skipped so it doesn’t keep getting read off a queue or topic
• When: Whenever you can’t process something immediately, but must process it later
• Why: Not everything will arrive in the order in which you expect it – if you need a resequencing aggregator this is a good option
• How: Call BrokeredMessage.Defer BUT SAVE the SequenceNumber
• Impact: Provide logical ordered processing even if your senders are chaotic
If you lose the sequence number of a message there is no way to read it
WARNING
Auto Forward
• What: Forward all messages to another entity
• When: If current senders have an address you don’t want to use anymore – or if you want more fine grained security
• Why: Change is hard – getting others to change can be impossible!
• How: Set the ForwardTo property on the Queue or the Subscription (for a topic)
• Impact: Free yourself from decisions you or someone else made last year
Actions on Subscriptions
• What: Change message properties when a subscription receives a message
• When: You want to create rich topologies
• Why: • Actions allow you to set user properties that can change routing
• This allows expression of any sort of decision tree – almost like BRE
• How: Use the Action property of the RuleDescription
• Impact: Chaining rules with actions allows for creating very rich topologies that can express almost any logic But maybe shouldn’t
Dead lettering with Auto forward
• What: Send dead letter messages to another entity (queue / topic)
• When: you want more control over where non-deliverable messages go
• Why: Not all messages fail for the same reason – forwarding to another entity enables rich failure routing
• How: Use the ForwardDeadLetteredMessagesTo property on Queue or Subscription
Auto-delete on idle
• What: Delete entities that do not have a Send operation called for a certain amount of time
• When: You need to create entities for specific flows or scenarios that are transient in nature and don’t want to clean them up
• Why: No one ever wants to clean up their room – we’ll do it for you
• How: Specify a timespan for AutoDeleteOnIdle on the queue or topic
• Impact: A clean namespace is a happy namespace
OnMessage (.NET Client Only)
• What: A messaging pump that makes dispatching and processing messages far easier.
• When: Any time you’re reading Service Bus in .NET
• Why: This is our modern approach – we’re making our client easier to use - think of EventProcessorHost
• How: Set a lambda or function on OnMessage of the QueueClient or SubscriptionClient
• Impact: Do more with less.