SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 

Kürzlich hochgeladen (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Empfohlen

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
 

Empfohlen (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

Hinweis der Redaktion

  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