SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
Building enterprise
                           applications with
                             NServiceBus
                                   Andreas Öhlund

                               twitter: @andreasohlund
                           blog: andreasohlund.blogspot.com




tisdag den 15 juni 2010
What is a distributed
                                system?
                          “A distributed system is one in which the
                          failure of a computer you didn't even
                          know existed can render your own
                          computer unusable”
                                                    -Leslie Lamport




tisdag den 15 juni 2010
The first rule of NServiceBus
tisdag den 15 juni 2010
There is NO Service Bus!


                  The first rule of NServiceBus
tisdag den 15 juni 2010
Well, at least no physical one
tisdag den 15 juni 2010
The key to robust communication




tisdag den 15 juni 2010
Store and forward




tisdag den 15 juni 2010
Request/Response the
                        NServiceBus way

                          Fire and forget X 2




tisdag den 15 juni 2010
The effects of
              tight coupling
                          Temporal
                          Behavioral




tisdag den 15 juni 2010
Communication and
                              coupling
              Low
                            command - oriented         event - oriented



 Temporal


                             distributed 3-layer      Emergency services
              High




                            High                              Low
                                        Behavioural
tisdag den 15 juni 2010
Coupling NServiceBus style

              Low         Command - oriented         Event - oriented



 Temporal

              High         Distributed 3-layer      Emergency services




                          High        Behavioural              Low

tisdag den 15 juni 2010
Command oriented
                           communication
                                          CompleteSaleCommand



                            OnlineSales                         OrderService




tisdag den 15 juni 2010
Sending Messages
                               IBus.Send()
                          bus.Send(new CompleteSaleCommand
                                                  CreateOrderCommand
                             {
                               ProductId = 123,
                                    OnlineSales

                               Quantity = 10
                               ....
                             });




tisdag den 15 juni 2010
Receiving and
                    processing of messages
                   public class CompleteSaleMessageHandler:
                CreateOrderCommand

                      IHandleMessages<CompleteSaleCommand>
                   {                 OrderService



                      public void Handle(CompleteSaleCommand c)
                      {
                        ...
                      }
                   }


tisdag den 15 juni 2010
Throttling the load
                          • Manage traffic peaks
                          • Consumer controls the pace
                          • <MsmqTransportConfig
                            NumberOfWorkerThreads="3" />




tisdag den 15 juni 2010
What happens when the load
                  becomes to heavy for one server?




tisdag den 15 juni 2010
Scaling with the Distributor




tisdag den 15 juni 2010
Building consistent systems

                     •    Do we produce
                          predictable results even
                          under failure conditions?

                     •    What about non
                          transactional sources?




tisdag den 15 juni 2010
Isolate non transactional sources as
                            separate endpoints

                  public void Handle(CompleteSaleCommand cmd)
                  {
                     var order = ....
                     orderRepository.Save(order)

                          smtpClient.Send(new MailMessage{...})
                  }




tisdag den 15 juni 2010
Isolate non transactional sources as
                            separate endpoints
                   public void Handle(CompleteSaleCommand cmd)
                   {
                  public void Handle(CompleteSaleCommand cmd)
                  {   var order = ....
                      orderRepository.Save(order)
                     var order = ....
                     orderRepository.Save(order)
                      bus.Send(new NotifyCustomerRequest
                                {
                     smtpClient.Send(new MailMessage{...})
                  }                 EmailAddress = customer.Email,
                                    Body = “Order confirmation”
                                });
                   }

tisdag den 15 juni 2010
When things go wrong




tisdag den 15 juni 2010
Messaging gives you a
                          chance to do better

                     • No more showing the users a WSOD
                     • Messages are replayable
                     • Async communication opens up a crucial
                          windows of time for corrections




tisdag den 15 juni 2010
Coupling NServiceBus style

                   Low    Command - oriented         Event - oriented



 Temporal

                  High     Distributed 3-layer      Emergency services




                          High                             Low
                                      Behavioural
tisdag den 15 juni 2010
Publish and subscribe




tisdag den 15 juni 2010
Billing

                                                              BillingService




                                         OrderAcceptedEvent
                                                                                   Shipping
                          SalesService




                                                                               ShippingService




                          Sales


                          Business events
tisdag den 15 juni 2010
Finally a chance to discuss non functional
                  requirements that business people understand

tisdag den 15 juni 2010
The mechanics of pub/sub




tisdag den 15 juni 2010
The mechanics of pub/sub




tisdag den 15 juni 2010
Becoming a subscriber

                bus.Subcribe<IOrderAcceptedEvent>();




tisdag den 15 juni 2010
Publishing
                  bus.Publish<IOrderAcceptedEvent>(x=>
                     {
                       ProductId = 123,
                       Quantity = 10
                       ....
                     });




tisdag den 15 juni 2010
It’s hard to get it right
                           the first time around




tisdag den 15 juni 2010
Versioning events using interfaces

                          public interface IOrderAcceptedEvent2 :
                                             IOrderAcceptedEvent
                          {
                             string SomeNewProperty{ get;set; }
                          }




tisdag den 15 juni 2010
Configuration
        Developers:
                    use code
        Administrators:
                    use config files




tisdag den 15 juni 2010
Getting your stuff to
                              production




tisdag den 15 juni 2010
The generic host to the rescue




tisdag den 15 juni 2010
The generic host to the rescue



                          public class EndpointConfig:
                                        IConfigureThisEndpoint,
                                        AsA_Publisher
                          {

                          }


tisdag den 15 juni 2010
Using profiles to adapt to different
                                environments
tisdag den 15 juni 2010
NServiceBus is
            opinionated




tisdag den 15 juni 2010
Why all these opinions?




tisdag den 15 juni 2010
The end

                     • www.nservicebus.com
                     • www.udidahan.com/blog
                     • andreasohlund.blogspot.com



tisdag den 15 juni 2010

Weitere ähnliche Inhalte

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

NServiceBus-Devsum10

  • 1. Building enterprise applications with NServiceBus Andreas Öhlund twitter: @andreasohlund blog: andreasohlund.blogspot.com tisdag den 15 juni 2010
  • 2. What is a distributed system? “A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable” -Leslie Lamport tisdag den 15 juni 2010
  • 3. The first rule of NServiceBus tisdag den 15 juni 2010
  • 4. There is NO Service Bus! The first rule of NServiceBus tisdag den 15 juni 2010
  • 5. Well, at least no physical one tisdag den 15 juni 2010
  • 6. The key to robust communication tisdag den 15 juni 2010
  • 7. Store and forward tisdag den 15 juni 2010
  • 8. Request/Response the NServiceBus way Fire and forget X 2 tisdag den 15 juni 2010
  • 9. The effects of tight coupling Temporal Behavioral tisdag den 15 juni 2010
  • 10. Communication and coupling Low command - oriented event - oriented Temporal distributed 3-layer Emergency services High High Low Behavioural tisdag den 15 juni 2010
  • 11. Coupling NServiceBus style Low Command - oriented Event - oriented Temporal High Distributed 3-layer Emergency services High Behavioural Low tisdag den 15 juni 2010
  • 12. Command oriented communication CompleteSaleCommand OnlineSales OrderService tisdag den 15 juni 2010
  • 13. Sending Messages IBus.Send() bus.Send(new CompleteSaleCommand CreateOrderCommand { ProductId = 123, OnlineSales Quantity = 10 .... }); tisdag den 15 juni 2010
  • 14. Receiving and processing of messages public class CompleteSaleMessageHandler: CreateOrderCommand IHandleMessages<CompleteSaleCommand> { OrderService public void Handle(CompleteSaleCommand c) { ... } } tisdag den 15 juni 2010
  • 15. Throttling the load • Manage traffic peaks • Consumer controls the pace • <MsmqTransportConfig NumberOfWorkerThreads="3" /> tisdag den 15 juni 2010
  • 16. What happens when the load becomes to heavy for one server? tisdag den 15 juni 2010
  • 17. Scaling with the Distributor tisdag den 15 juni 2010
  • 18. Building consistent systems • Do we produce predictable results even under failure conditions? • What about non transactional sources? tisdag den 15 juni 2010
  • 19. Isolate non transactional sources as separate endpoints public void Handle(CompleteSaleCommand cmd) { var order = .... orderRepository.Save(order) smtpClient.Send(new MailMessage{...}) } tisdag den 15 juni 2010
  • 20. Isolate non transactional sources as separate endpoints public void Handle(CompleteSaleCommand cmd) { public void Handle(CompleteSaleCommand cmd) { var order = .... orderRepository.Save(order) var order = .... orderRepository.Save(order) bus.Send(new NotifyCustomerRequest { smtpClient.Send(new MailMessage{...}) } EmailAddress = customer.Email, Body = “Order confirmation” }); } tisdag den 15 juni 2010
  • 21. When things go wrong tisdag den 15 juni 2010
  • 22. Messaging gives you a chance to do better • No more showing the users a WSOD • Messages are replayable • Async communication opens up a crucial windows of time for corrections tisdag den 15 juni 2010
  • 23. Coupling NServiceBus style Low Command - oriented Event - oriented Temporal High Distributed 3-layer Emergency services High Low Behavioural tisdag den 15 juni 2010
  • 24. Publish and subscribe tisdag den 15 juni 2010
  • 25. Billing BillingService OrderAcceptedEvent Shipping SalesService ShippingService Sales Business events tisdag den 15 juni 2010
  • 26. Finally a chance to discuss non functional requirements that business people understand tisdag den 15 juni 2010
  • 27. The mechanics of pub/sub tisdag den 15 juni 2010
  • 28. The mechanics of pub/sub tisdag den 15 juni 2010
  • 29. Becoming a subscriber bus.Subcribe<IOrderAcceptedEvent>(); tisdag den 15 juni 2010
  • 30. Publishing bus.Publish<IOrderAcceptedEvent>(x=> { ProductId = 123, Quantity = 10 .... }); tisdag den 15 juni 2010
  • 31. It’s hard to get it right the first time around tisdag den 15 juni 2010
  • 32. Versioning events using interfaces public interface IOrderAcceptedEvent2 : IOrderAcceptedEvent { string SomeNewProperty{ get;set; } } tisdag den 15 juni 2010
  • 33. Configuration Developers: use code Administrators: use config files tisdag den 15 juni 2010
  • 34. Getting your stuff to production tisdag den 15 juni 2010
  • 35. The generic host to the rescue tisdag den 15 juni 2010
  • 36. The generic host to the rescue public class EndpointConfig: IConfigureThisEndpoint, AsA_Publisher { } tisdag den 15 juni 2010
  • 37. Using profiles to adapt to different environments tisdag den 15 juni 2010
  • 38. NServiceBus is opinionated tisdag den 15 juni 2010
  • 39. Why all these opinions? tisdag den 15 juni 2010
  • 40. The end • www.nservicebus.com • www.udidahan.com/blog • andreasohlund.blogspot.com tisdag den 15 juni 2010