1 / 46

NserviceBus on Azure

NserviceBus on Azure. Jim Pelletier @ pjimmy mail@thejimmyp.com. The Plan™. Show you NServiceBus (Running on premises) Why it’s scalable Why it’s productive (awesome sauce) Show you how to move it to Azure Show you how to avoid Azure’s traps. Broker Architectural Style.

mandel
Télécharger la présentation

NserviceBus on Azure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NserviceBus on Azure Jim Pelletier @pjimmy mail@thejimmyp.com

  2. The Plan™ • Show you NServiceBus (Running on premises) • Why it’s scalable • Why it’s productive (awesome sauce) • Show you how to move it to Azure • Show you how to avoid Azure’s traps

  3. Broker Architectural Style Also known as “Hub and Spoke” and “Mediator” Designed to avoid having to change apps – EAI App 8 App 1 App 9 App 7 App 2 Broker App 6 App 3 App 5 App 4

  4. Bus Architectural Style • Event source and sinks use bus for pub/sub • Designed to allow independent evolution of sources and sinks Source Sink Bus Sink Source

  5. What is a Service Bus? There is no bus…

  6. Bus Topology App App App App Bus.dll Bus.dll Bus.dll Bus.dll App App App App Bus.dll Bus.dll Bus.dll Bus.dll

  7. Features & Patterns • Send Commands • Publish Events • Processing Pipelines • Sagas • Unit Testing

  8. Messaging & Queues Server Logically one-way: All information transferred in the message Client

  9. Messaging & Queues Server MSMQ OutgoingIncoming Store & Forward writes to disk Resilient in the face of failures MSMQ OutgoingIncoming Client

  10. Messaging & Queues • Modelled as a command • Tell someone to do something

  11. Demo • Host • Send Command • Subscription Storage • Saga Persistence • Hosting

  12. Subscriber Publisher Subscribe Subscriber Subscriber Subscriber Subscriber

  13. Subscriber Publisher abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh Subscriber Subscriber Subscriber Subscriber

  14. Pub /Sub • Modelled as events • Let everyone (or anyone) know something happened

  15. Demo • Pub Sub • Subscription Storage • Saga Persistence • Hosting

  16. Pipelines & Polymorhpism Order Placed Order Service Place Order Handler Takes Order Place Order Billing Service Customer Billed Order Placed Handler Bills Customer when Max Debt Reached Customer Care Service Order Confirmation Handler Sends confirmation email to customer Customer Billed

  17. Pipelines & Polymorhpism First Order Placed Order Service Place Order Handler Takes Order Place Order Billing Service Customer Billed Order Placed Handler Bills Customer when Max Debt Reached Customer Care Service Order Confirmation Handler Sends confirmation email to customer Customer Billed Welcome New Customer Handler Sends Catalogue & Welome Pack To New Customer Customer Welcomed

  18. Demo • Pipelines & Polymorphism • Subscription Storage • Saga Persistence • Hosting

  19. Decisions Based on Past Events Order Service Place Order Order Placed Billing Service Current Debt > Max Debt Customer Billed Customer ID Max Debt Current Balance Set Max Debit For Customer

  20. Demo • Sagas • Subscription Storage • Saga Persistence • Hosting

  21. Local Infrastructure • Queues • Subscription Storage • Saga Persistence • Hosting

  22. On Premises Infrastructure • Queues MSMQs

  23. On Premises Infrastructure • Subscription Storage • Saga Persistence • Subscription Storage • Saga Persistence • Hosting

  24. On Premises Infrastructure • Hosting • Subscription Storage • Saga Persistence • Hosting

  25. Infrastructure Options

  26. Demo • Move it to Azure

  27. Queuing with Azure • Storage Queues and App Fabric Queues • Built in back off of polling to reduce cost

  28. Queuing with Storage Queues • Storage Queues do not support transactions • Queue Peek Lock • Possible multiple processing so need to be idempotent • Limit imposed • Small payload size • Can use data bus to get over size limit

  29. Queuing with App Fabric Queues • Supports for exactly once delivery • Higher Message Size • No throughput limits imposed

  30. Dedicated Hosting • Runs in a Worker Role

  31. Shared Hosting • Runs in a Worker Role • Loads zip packages from blob storage

  32. Web Workers • Runs in a Web Role • Loads zip packages from blob storage • You can run workers in a web role

  33. Sagas • Will create the schema for you via NHibernate • Remember Table Storage type limitations

  34. Lack of Transactions & DTC • The biggest challenge in Azure vs. On Premise • Several strategies available • Idempotence • Sagas

  35. Messaging and Consistency – On Premises DTx Q Receive Handler DB Decrement Inventory $$ Order Decrement Account Some Operation Rollback Rollback The order is back in the queue

  36. Messaging and Consistency – On Premises We retry DTx Q Receive Handler DB Decrement Inventory $$ Order Record Order Decrement Account DB in consistent state

  37. Messaging and Consistency – On Azure QPL Q Receive Handler DB Decrement Inventory $$ Order Decrement Account Some Operation Rollback 2 txns commit The order is back in the queue But DB Has been written

  38. Messaging and Consistency – On Azure We retry QPL Q Receive Handler DB Decrement Account Record Order Decrement Inventory 3txns commit Now account & inventory decremented twice

  39. Messaging and Consistency – QPL Timeouts QPL Timout QPL Q Receive DB Handler Some operation response Some operation request $$ Order The order is back in the queue

  40. Messaging and Consistency – QPL Timeouts QPL Timout QPL Q Receive DB Handler Some operation response Some operation request $$ Order The order is back in the queue

  41. Messaging and Consistency – QPL Timeouts We retry QPL Q Receive DB Handler Some operation response Some operation request $$ Order Operation has been run twice

  42. Messaging and Consistency – On AzureAn example of idempotence QPL Timout QPL Q Receive DB Handler Check for outwards inventory movement Check for debit record Add outward inventory movement Add debit to account ledger $$ Order Some Operation 2 operations committed The order is back in the queue Rollback

  43. Messaging and Consistency – On AzureAn example of idempotence QPL Q Receive DB Handler Check record of order Check for outwards inventory movement Check for debit record Add record for order $$ Order 1 operation committed 3 operations committed total DB is in a consistent state

  44. Keeping Azure Consistant • Multiple operations can get gnarly quick! • Use idempotence • Track state of remote op with saga • Success – Do nothing (we’re already done) • Pending – Try again (we might still fail) • Failure - Compensate

  45. Resources • http://www.nservicebus.com/Documentation.aspx • http://cloudshaper.wordpress.com/ • http://tech.groups.yahoo.com/group/nservicebus

  46. The Plug Enterprise Development with NServiceBus A 3 day course on NSB written by UdiDahan & delivered by yours truly http://nsbdecember2012.eventbrite.com.au/ Jim Pelletier @pjimmy mail@thejimmyp.com

More Related