SlideShare une entreprise Scribd logo
1  sur  70
Reliable integrations
 with NServiceBus

Andreas Öhlund
Enterprise Development Expert
Agenda

• War story
• Dragons and how to manage them
• A “saga” with a happy ending
• Q &A
Fact:
A trip to dragon territory can
take a while...
The usual way
public void Handle(OrderPlaced message)
{
    var order = new Order{ Id = message.OrderID };

    order.TrackingCode = fedex.BookPickup(order);

    order.Status = ShippingStatus.PickupBooked;

    repository.Save(order);
}
The usual way
public void Handle(OrderPlaced message)
{
    var order = new Order{ Id = message.OrderID };

    2: order.TrackingCode = fedex.BookPickup(order);
    3: order.Status = ShippingStatus.PickupBooked;
      repository.Save(order);
}
The usual way
public void Handle(OrderPlaced message)
{
    var order = new Order{ Id = message.OrderID };

    2: order.TrackingCode = fedex.BookPickup(order);
          This might take a while!
    3: order.Status = ShippingStatus.PickupBooked;
      repository.Save(order);
}
Fact:
Dragons doesn’t support
transactions.
Database rollback
Order
             Ship



        TX
             Store
                     DB
Database rollback
Order
             Ship



        TX
             Store
                     DB
Database rollback
Order
             Ship



        TX
             Store
                     DB
Database rollback
Order            No TX
                Support
             Ship



        TX
             Store
                      DB
Database rollback
Did we just loose an order?
          Order                   No TX
                                 Support
                              Ship



                     TX
                              Store
                                       DB
Database rollback
Order            No TX
                Support
             Ship



        TX
             Store
                      DB
Database rollback
        Order            No TX
                        Support
                     Ship


Order
Http            TX
                     Store
                              DB
Design guideline


“Interact with non transactional resources
using separate endpoints”
R# Extract endpoint
 public void Handle(OrderPlaced message)
{
         repository.Save(new Order
               {
                  Id = message.OrderID,
                  Status = ShippingStatus.AwaitingShipment
                });

        bus.Send<BookShipment>(m =>
          {
              m.OrderID = message.OrderID;
          });
}
R# Extract endpoint
 public void Handle(OrderPlaced message)
{
         repository.Save(new Order
               {
                  Id = message.OrderID,
                  Status = ShippingStatus.AwaitingShipment
                });

        bus.Send<BookShipment>(m =>
          {
              m.OrderID = message.OrderID;
          });
}
R# Extract endpoint
 public void Handle(OrderPlaced message)
{
         repository.Save(new Order
               {
                  Id = message.OrderID,
                  Status = ShippingStatus.AwaitingShipment
                });

        bus.Send<BookShipment>(m =>
          {
              m.OrderID = message.OrderID;
          });
}
R# Extract endpoint
public void Handle(ShipmentBooked message)
{
  var order = repository.Get<Order>(message.OrderID);

    order.TrackingCode = message.TrackingCode;

    repository.Save(order);
}
Consistency across
    rollbacks
 Order




         TX
Consistency across
    rollbacks
 Order

              Store
                      DB


         TX
Consistency across
    rollbacks
 Order

                Store
                        DB


         TX

              Book shipment   MQ
Consistency across
    rollbacks
 Order

                Store
                        DB


         TX

              Book shipment   MQ
Consistency across
    rollbacks
 Order

                Store
                        DB


         TX

              Book shipment   MQ
Consistency across
    rollbacks
 Order

                Store
                        DB


         TX

              Book shipment   MQ
Fact:
Not everyone will make it back.




  Not all return from a trip to the dragons
What happens if the
       response is lost?
BookShipment

                    Fedex.Ship


               TX
What happens if the
       response is lost?
BookShipment

                      Fedex.Ship
                    TimeoutException
               TX
What happens if the
       response is lost?
BookShipment

                      Fedex.Ship
                    TimeoutException
               TX
What happens if the
       response is lost?
BookShipment

                      Fedex.Ship   Commit

                    TimeoutException
               TX
Idempotency
BookShipment




          Integration
           Endpoint
Idempotency
BookShipment

                        http://fedex.com/ship ?id=xyz123


          Integration
           Endpoint
Idempotency
BookShipment

                        http://fedex.com/ship ?id=xyz123
                                              Commit


          Integration
           Endpoint
Idempotency
BookShipment

                        http://fedex.com/ship ?id=xyz123
                                              Commit
                          TimeoutException
                                 X
          Integration
           Endpoint
Idempotency
BookShipment

                        http://fedex.com/ship ?id=xyz123
                                              Commit
                          TimeoutException
                                 X
          Integration
           Endpoint

                        http://fedex.com/ship ?id=xyz123
Idempotency
BookShipment

                        http://fedex.com/ship ?id=xyz123
                                              Commit
                          TimeoutException
                                 X
          Integration
           Endpoint

                        http://fedex.com/ship ?id=xyz123


                                              Discard
Idempotency
BookShipment

                        http://fedex.com/ship ?id=xyz123
                                              Commit
                          TimeoutException
                                 X
          Integration
           Endpoint

                        http://fedex.com/ship ?id=xyz123


                                              Discard
Idempotency
 BookShipment

                          http://fedex.com/ship ?id=xyz123
                                                Commit
                            TimeoutException
                                   X
            Integration
             Endpoint

                          http://fedex.com/ship ?id=xyz123
ShipmentBooked
                                                Discard
Fact:
A trip to the dragons may be costly.
Timeouts vNext


• Thread.Sleep is not a good solution
• Need a way to have durable timeouts
• The NServiceBus timeout manager solves
  this for us
Fact:
Dragons have home turf advantage.
Scalable integrations

  Use throttling to:

          • Manage traffic peaks
          • Allow you to control the pace
A more scalable design


Client                 Server
A more scalable design
            Request



Client                 Server
A more scalable design
            Request             Send



Client                 Server
A more scalable design
                 Request                                Send
         Ticket - come back in T
           http://fedex.com/responses/xyz123


Client                                         Server
A more scalable design
                 Request                                Send
         Ticket - come back in T
           http://fedex.com/responses/xyz123


Client                                         Server


                                                        Recv
                                               Cache
A more scalable design
                         Request                                Send
                 Ticket - come back in T


         }
                   http://fedex.com/responses/xyz123


Client       T                                         Server

         http://fedex.com/responses/xyz123
                                                                Recv
                                                       Cache
A more scalable design
                         Request                                Send
                 Ticket - come back in T


         }
                   http://fedex.com/responses/xyz123


Client       T                                         Server

         http://fedex.com/responses/xyz123
                                                                Recv
             Response / come back in T2                Cache
A more scalable design
                         Request                                Send
                 Ticket - come back in T


         }
                   http://fedex.com/responses/xyz123


Client       T                                         Server

         http://fedex.com/responses/xyz123
                                                                Recv
             Response / come back in T2                Cache
A more scalable design
                         Request                                Send
                 Ticket - come back in T


         }
                   http://fedex.com/responses/xyz123


Client       T                                         Server

         http://fedex.com/responses/xyz123
                                                                Recv
             Response / come back in T2                Cache
Using sagas to control
BookShipment
             message flow


     Integration              Fedex
                   Timeout              Fedex
         Saga                Endpoint
                   Manager
Using sagas to control
BookShipment
             message flow
                   Get ticket



     Integration                      Fedex
                           Timeout              Fedex
         Saga                        Endpoint
                           Manager
Using sagas to control
BookShipment
             message flow
                   Get ticket



     Integration                      Fedex
                           Timeout              Fedex
         Saga                        Endpoint
                           Manager
Using sagas to control
BookShipment
             message flow
                   Get ticket



     Integration                      Fedex
                           Timeout              Fedex
         Saga                        Endpoint
                           Manager
Using sagas to control
BookShipment
             message flow
                        Get ticket


                   Wake me up in T
     Integration                           Fedex
                                Timeout              Fedex
         Saga                             Endpoint
                                Manager
Using sagas to control
BookShipment
             message flow
                        Get ticket


                   Wake me up in T
     Integration                           Fedex
                                Timeout              Fedex
         Saga                             Endpoint
                                Manager
Using sagas to control
BookShipment
             message flow
                        Get ticket


                   Wake me up in T
     Integration                           Fedex
                                Timeout              Fedex
         Saga                             Endpoint
                                Manager

                         Get Data
Using sagas to control
BookShipment
             message flow
                        Get ticket


                   Wake me up in T
     Integration                           Fedex
                                Timeout              Fedex
         Saga                             Endpoint
                                Manager

                         Get Data
Using sagas to control
BookShipment
             message flow
                        Get ticket


                   Wake me up in T
     Integration                           Fedex
                                Timeout              Fedex
         Saga                             Endpoint
                                Manager

                         Get Data
Code...
Thanks for listening!
Thanks for listening!




 Andreas Öhlund
 Enterprise Development Expert

Contenu connexe

Dernier

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Dernier (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
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
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
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...
 

Reliable integrations with NServiceBus

  • 1. Reliable integrations with NServiceBus Andreas Öhlund Enterprise Development Expert
  • 2. Agenda • War story • Dragons and how to manage them • A “saga” with a happy ending • Q &A
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. Fact: A trip to dragon territory can take a while...
  • 10. The usual way public void Handle(OrderPlaced message) { var order = new Order{ Id = message.OrderID }; order.TrackingCode = fedex.BookPickup(order); order.Status = ShippingStatus.PickupBooked; repository.Save(order); }
  • 11. The usual way public void Handle(OrderPlaced message) { var order = new Order{ Id = message.OrderID }; 2: order.TrackingCode = fedex.BookPickup(order); 3: order.Status = ShippingStatus.PickupBooked; repository.Save(order); }
  • 12. The usual way public void Handle(OrderPlaced message) { var order = new Order{ Id = message.OrderID }; 2: order.TrackingCode = fedex.BookPickup(order); This might take a while! 3: order.Status = ShippingStatus.PickupBooked; repository.Save(order); }
  • 14. Database rollback Order Ship TX Store DB
  • 15. Database rollback Order Ship TX Store DB
  • 16. Database rollback Order Ship TX Store DB
  • 17. Database rollback Order No TX Support Ship TX Store DB
  • 18. Database rollback Did we just loose an order? Order No TX Support Ship TX Store DB
  • 19. Database rollback Order No TX Support Ship TX Store DB
  • 20. Database rollback Order No TX Support Ship Order Http TX Store DB
  • 21. Design guideline “Interact with non transactional resources using separate endpoints”
  • 22. R# Extract endpoint public void Handle(OrderPlaced message) { repository.Save(new Order { Id = message.OrderID, Status = ShippingStatus.AwaitingShipment }); bus.Send<BookShipment>(m => { m.OrderID = message.OrderID; }); }
  • 23. R# Extract endpoint public void Handle(OrderPlaced message) { repository.Save(new Order { Id = message.OrderID, Status = ShippingStatus.AwaitingShipment }); bus.Send<BookShipment>(m => { m.OrderID = message.OrderID; }); }
  • 24. R# Extract endpoint public void Handle(OrderPlaced message) { repository.Save(new Order { Id = message.OrderID, Status = ShippingStatus.AwaitingShipment }); bus.Send<BookShipment>(m => { m.OrderID = message.OrderID; }); }
  • 25. R# Extract endpoint public void Handle(ShipmentBooked message) { var order = repository.Get<Order>(message.OrderID); order.TrackingCode = message.TrackingCode; repository.Save(order); }
  • 26. Consistency across rollbacks Order TX
  • 27. Consistency across rollbacks Order Store DB TX
  • 28. Consistency across rollbacks Order Store DB TX Book shipment MQ
  • 29. Consistency across rollbacks Order Store DB TX Book shipment MQ
  • 30. Consistency across rollbacks Order Store DB TX Book shipment MQ
  • 31. Consistency across rollbacks Order Store DB TX Book shipment MQ
  • 32. Fact: Not everyone will make it back. Not all return from a trip to the dragons
  • 33. What happens if the response is lost? BookShipment Fedex.Ship TX
  • 34. What happens if the response is lost? BookShipment Fedex.Ship TimeoutException TX
  • 35. What happens if the response is lost? BookShipment Fedex.Ship TimeoutException TX
  • 36. What happens if the response is lost? BookShipment Fedex.Ship Commit TimeoutException TX
  • 37. Idempotency BookShipment Integration Endpoint
  • 38. Idempotency BookShipment http://fedex.com/ship ?id=xyz123 Integration Endpoint
  • 39. Idempotency BookShipment http://fedex.com/ship ?id=xyz123 Commit Integration Endpoint
  • 40. Idempotency BookShipment http://fedex.com/ship ?id=xyz123 Commit TimeoutException X Integration Endpoint
  • 41. Idempotency BookShipment http://fedex.com/ship ?id=xyz123 Commit TimeoutException X Integration Endpoint http://fedex.com/ship ?id=xyz123
  • 42. Idempotency BookShipment http://fedex.com/ship ?id=xyz123 Commit TimeoutException X Integration Endpoint http://fedex.com/ship ?id=xyz123 Discard
  • 43. Idempotency BookShipment http://fedex.com/ship ?id=xyz123 Commit TimeoutException X Integration Endpoint http://fedex.com/ship ?id=xyz123 Discard
  • 44. Idempotency BookShipment http://fedex.com/ship ?id=xyz123 Commit TimeoutException X Integration Endpoint http://fedex.com/ship ?id=xyz123 ShipmentBooked Discard
  • 45. Fact: A trip to the dragons may be costly.
  • 46. Timeouts vNext • Thread.Sleep is not a good solution • Need a way to have durable timeouts • The NServiceBus timeout manager solves this for us
  • 47. Fact: Dragons have home turf advantage.
  • 48. Scalable integrations Use throttling to: • Manage traffic peaks • Allow you to control the pace
  • 49. A more scalable design Client Server
  • 50. A more scalable design Request Client Server
  • 51. A more scalable design Request Send Client Server
  • 52. A more scalable design Request Send Ticket - come back in T http://fedex.com/responses/xyz123 Client Server
  • 53. A more scalable design Request Send Ticket - come back in T http://fedex.com/responses/xyz123 Client Server Recv Cache
  • 54. A more scalable design Request Send Ticket - come back in T } http://fedex.com/responses/xyz123 Client T Server http://fedex.com/responses/xyz123 Recv Cache
  • 55. A more scalable design Request Send Ticket - come back in T } http://fedex.com/responses/xyz123 Client T Server http://fedex.com/responses/xyz123 Recv Response / come back in T2 Cache
  • 56. A more scalable design Request Send Ticket - come back in T } http://fedex.com/responses/xyz123 Client T Server http://fedex.com/responses/xyz123 Recv Response / come back in T2 Cache
  • 57. A more scalable design Request Send Ticket - come back in T } http://fedex.com/responses/xyz123 Client T Server http://fedex.com/responses/xyz123 Recv Response / come back in T2 Cache
  • 58. Using sagas to control BookShipment message flow Integration Fedex Timeout Fedex Saga Endpoint Manager
  • 59. Using sagas to control BookShipment message flow Get ticket Integration Fedex Timeout Fedex Saga Endpoint Manager
  • 60. Using sagas to control BookShipment message flow Get ticket Integration Fedex Timeout Fedex Saga Endpoint Manager
  • 61. Using sagas to control BookShipment message flow Get ticket Integration Fedex Timeout Fedex Saga Endpoint Manager
  • 62. Using sagas to control BookShipment message flow Get ticket Wake me up in T Integration Fedex Timeout Fedex Saga Endpoint Manager
  • 63. Using sagas to control BookShipment message flow Get ticket Wake me up in T Integration Fedex Timeout Fedex Saga Endpoint Manager
  • 64. Using sagas to control BookShipment message flow Get ticket Wake me up in T Integration Fedex Timeout Fedex Saga Endpoint Manager Get Data
  • 65. Using sagas to control BookShipment message flow Get ticket Wake me up in T Integration Fedex Timeout Fedex Saga Endpoint Manager Get Data
  • 66. Using sagas to control BookShipment message flow Get ticket Wake me up in T Integration Fedex Timeout Fedex Saga Endpoint Manager Get Data
  • 68.
  • 70. Thanks for listening! Andreas Öhlund Enterprise Development Expert

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. Fallacies of distributed computing\n
  12. Good DDD but still dangerous\nWorks well in test, but takes a long time in production\nKeeps the transactions open longer (other handlers can have opened the db connection\nFallacy: Latency is zero\n
  13. Good DDD but still dangerous\nWorks well in test, but takes a long time in production\nKeeps the transactions open longer (other handlers can have opened the db connection\nFallacy: Latency is zero\n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. Find a way to break up the process\nIntroducing a new status\n
  23. Find a way to break up the process\nIntroducing a new status\n
  24. \n
  25. Consistent processing of orders\n
  26. Consistent processing of orders\n
  27. Consistent processing of orders\n
  28. Consistent processing of orders\n
  29. Consistent processing of orders\n
  30. \n
  31. Fallacy: the network is reliable\nRetries might cause problems\nNot idempotent\n \n\n
  32. Fallacy: the network is reliable\nRetries might cause problems\nNot idempotent\n \n\n
  33. Fallacy: the network is reliable\nRetries might cause problems\nNot idempotent\n \n\n
  34. Requires collaboration with the other party\nNServiceBus preserves message ids even across the error queue\n\n
  35. Requires collaboration with the other party\nNServiceBus preserves message ids even across the error queue\n\n
  36. Requires collaboration with the other party\nNServiceBus preserves message ids even across the error queue\n\n
  37. Requires collaboration with the other party\nNServiceBus preserves message ids even across the error queue\n\n
  38. Requires collaboration with the other party\nNServiceBus preserves message ids even across the error queue\n\n
  39. Requires collaboration with the other party\nNServiceBus preserves message ids even across the error queue\n\n
  40. Requires collaboration with the other party\nNServiceBus preserves message ids even across the error queue\n\n
  41. Partner might charge per call\nOn a device with limited battery or where traffic cost might be high\n
  42. \n
  43. Sleep locks up threads, bad for throughput\nSleep doesn&amp;#x2019;t survive restarts\nMessage based alarm clock\n
  44. You play according to their rules\nDragons need to control the pace of the raiding parties\nMust do throttling to be scalable\nImpossible to maintain SLA&amp;#x2019;s otherwise\n
  45. \n
  46. The \n
  47. The \n
  48. The \n
  49. \n
  50. Msmq.Send is very quick, 7000msg/s given no DTC\nAdjust T to tune the load\nResponses can be served of different servers\nCQRS\nCallback protocol can be used if the number of clients are small (REST / HTTP)\n
  51. Msmq.Send is very quick, 7000msg/s given no DTC\nAdjust T to tune the load\nResponses can be served of different servers\nCQRS\nCallback protocol can be used if the number of clients are small (REST / HTTP)\n
  52. Msmq.Send is very quick, 7000msg/s given no DTC\nAdjust T to tune the load\nResponses can be served of different servers\nCQRS\nCallback protocol can be used if the number of clients are small (REST / HTTP)\n
  53. Msmq.Send is very quick, 7000msg/s given no DTC\nAdjust T to tune the load\nResponses can be served of different servers\nCQRS\nCallback protocol can be used if the number of clients are small (REST / HTTP)\n
  54. Msmq.Send is very quick, 7000msg/s given no DTC\nAdjust T to tune the load\nResponses can be served of different servers\nCQRS\nCallback protocol can be used if the number of clients are small (REST / HTTP)\n
  55. Msmq.Send is very quick, 7000msg/s given no DTC\nAdjust T to tune the load\nResponses can be served of different servers\nCQRS\nCallback protocol can be used if the number of clients are small (REST / HTTP)\n
  56. Msmq.Send is very quick, 7000msg/s given no DTC\nAdjust T to tune the load\nResponses can be served of different servers\nCQRS\nCallback protocol can be used if the number of clients are small (REST / HTTP)\n
  57. Msmq.Send is very quick, 7000msg/s given no DTC\nAdjust T to tune the load\nResponses can be served of different servers\nCQRS\nCallback protocol can be used if the number of clients are small (REST / HTTP)\n
  58. Picture == the essence of sagas\n * Only control logic\n\n
  59. Picture == the essence of sagas\n * Only control logic\n\n
  60. Picture == the essence of sagas\n * Only control logic\n\n
  61. Picture == the essence of sagas\n * Only control logic\n\n
  62. Picture == the essence of sagas\n * Only control logic\n\n
  63. Picture == the essence of sagas\n * Only control logic\n\n
  64. Picture == the essence of sagas\n * Only control logic\n\n
  65. Picture == the essence of sagas\n * Only control logic\n\n
  66. \n
  67. \n
  68. \n
  69. If we learn to manage our dragons they can be of great use\nTell the story on how we built our own queuing system\n\n
  70. If we learn to manage our dragons they can be of great use\nTell the story on how we built our own queuing system\n\n