Enterprise Integration Using REST: A Case Study

1,042 views

Published on

Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/TJhC44.

Brandon Byars discusses the constraints and the flexibility of nonpublic APIs, and lessons learned from scaling RESTful integration across more than a dozen teams. Filmed at qconlondon.com.

Brandon Byars is a technologist and principal consultant at ThoughtWorks. He has a wide range of experience in multiple technologies and business domains, with an interest in applying systems thinking to software development. Brandon has a particular interest in exploring the social and organizational aspects that allow software development to scale to large teams.

Published in: Technology, Business
  • Be the first to comment

Enterprise Integration Using REST: A Case Study

  1. 1. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /constraints-api-rest-integration
  2. 2. Presented at QCon London www.qconlondon.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  3. 3. enterprise REST a case study twitter:@BrandonByars!
  4. 4. the eight fallacies of distributed programming •  the network is reliable •  latency is zero •  bandwidth is infinite •  the network is secure •  topology doesn’t change •  there is one administrator •  transport cost is zero •  the network is homogenous
  5. 5. POX URI Resources! HTTP Standard Interface! HATEOA S Forcing people to use your links! RPC / SOAP!
  6. 6. Most REST mistakes happen over here…! versioning deployment testing service POX URI HTTP HATEOA S
  7. 7. REST
  8. 8. a story about a billing system...
  9. 9. a story about a legacy rewrite...
  10. 10. dramatis personae
  11. 11. dramatis personae order   management   order   entry   provisioning   product   catalog   customer   field  force   management   address   billing   inventory:   physical   inventory:   telephony   CSR   UI   Web  
  12. 12. Choreography... ...not orchestratio
  13. 13. define logical environments for isolation
  14. 14. Shared Integration VM! Bob’s Workstation! Order! O1! Product! P1!Mary’s Workstation! Order! O1! Customer! C1!
  15. 15. Shared Integration VM! Bob’s Workstation! Order! O1! Product! P2!Mary’s Workstation! Order! O1! Customer! C1! Product! P1! Customer! C2!
  16. 16. Shared Integration VM! Bob’s Workstation! Order! O1! Product! P2!Mary’s Workstation! Order! O1! Customer! C1! Product! P1! Customer! C2!
  17. 17. Shared Integration VM! Bob’s Workstation! Order! O1! Product! P2!Mary’s Workstation! Order! O1! Customer! C1! Product! P1! Customer! C2! Bob’s Environment! Mary’s Environment!
  18. 18. coordinated deployments
  19. 19. order-bob:! product:! webServers: [s1.test.dev] !! url: http://s1.test.dev:8000/products! dbServer: s1.test.dev! dbName: OrderBobProducts! customer:! webServers: [s1.test.dev]! url: http://s1.test.dev:8001/customers! dbServer: s1.test.dev! dbName: OrderBobCustomers! ! order-mary:! product:! webServers: [s1.test.dev]!
  20. 20. order-bob:! product:! webServers: [s1.test.dev] !! url: http://s1.test.dev:8000/products! dbServer: s1.test.dev! dbName: OrderBobProducts! customer:! webServers: [s1.test.dev]! url: http://s1.test.dev:8001/customers! dbServer: s1.test.dev! dbName: OrderBobCustomers! ! order-mary:! product:! webServers: [s1.test.dev]!
  21. 21. version as a last resort
  22. 22. 5.13.3! 4.1.1! Product! Order Entry! UI! Billing!
  23. 23. {! "customer": {! "firstName": "Fred",! "LastName": "Flinstone"! }! }! {! "customer": {! "firstName": "Fred",! "lastName": "Flinstone"! }! }! speling mistaeks
  24. 24. @RequestMapping(method=POST, produces=application/json)! @ResponseBody! public OrderResource createOrder(! !@RequestBody Order order,! !HttpServletResponse response! ) throws OrderException! {! !...! !...! }! Postel’s Law
  25. 25. separate functional testing from integration testing
  26. 26. Automated! Tests! Showcase! SIT! Pre-prod! Production!Commit! 2.16.1!3.0.6!3.0.6!3.1.3!3.1.11!3.1.12! deployment pipeline
  27. 27. Isolated Pipelines! SIT! Pre-prod! Production! 2.16.1!3.0.6!3.0.6!3.1.3!Order Entry! Billing! Product! UI! 4.1.1!4.1.2!4.2.0!4.2.3! 7.2.0!7.2.0!7.2.0!7.2.6! 2.1.33!2.2.0!2.2.0!2.2.5! deployment pipelines...
  28. 28. Isolation Tests! …! …! …! …!Commit! 2.16.1!3.0.6!3.0.6!3.1.3!3.1.11!3.1.12! early stages stub ruthlessly
  29. 29. System Under Test! Tests! Stub Server! hand-crafted stubs
  30. 30. System Under Test! Tests! Stub Server! record and replay stubs Real! Dependency!
  31. 31. System Under Test! Tests! Stub Server! general purpose stubs Stub! Setup!
  32. 32. Moco: https://github.com/dreamhead/moco ! vcr: https://github.com/vcr/vcr! ! βetamax: https://github.com/robfletcher/betamax! ! stubby4j: https://github.com/azagniotov/stubby4j! ! ! mountebank: http://www.mbtest.org/!
  33. 33. Isolation Tests! …! …! …! …!Commit! 2.16.1!3.0.6!3.0.6!3.1.3!3.1.11!3.1.12! early stages
  34. 34. Isolation Tests! …! …! …! …!Commit! 2.16.1!3.0.6!3.0.6!3.1.3!3.1.11!3.1.12! early stages Contract Tests!
  35. 35. Isolated Pipelines! Contract! Tests! Pre-prod! Production! 2.16.1!3.0.6!3.0.6!3.1.3!Order Entry! Billing! Product! UI! 4.1.1!4.1.2!4.2.0!4.2.3! 7.2.0!7.2.0!7.2.0!7.2.6! 2.1.33!2.2.0!2.2.0!2.2.5!
  36. 36. Contract! Tests! Artifacts!Isolated Pipelines! Tests! 3.1.2!Order Entry! Billing! Product! UI! 3.1.3! Tests! 4.2.3! 7.2.6! Tests! 2.2.5!
  37. 37. Contract! Tests! Artifacts!Isolated Pipelines! Tests! 3.1.3!Order Entry! Billing! Product! UI! 3.1.3! Tests! 4.2.3! 7.2.6! Tests! 2.2.5!
  38. 38. 7.2.6! 4.2.3! Product! Order Entry! UI! Billing!
  39. 39. Contract! Tests! Artifacts!Isolated Pipelines! Tests! 3.1.3!Order Entry! Billing! Product! UI! Tests! 4.2.3! 7.2.6! Tests! 2.2.5! Order Entry-3.1.3! Billing-4.2.3! Product-7.2.6! UI-2.2.5!
  40. 40. Contract! Tests! Artifacts!Isolated Pipelines! Tests! 3.1.3!Order Entry! Billing! Product! UI! Tests! 4.2.3! 7.2.6! Tests! 2.2.5!
  41. 41. [Test]   public  void  ValidateProductAttributes()   {          var  url  =  UrlForTestProduct();          var  response  =  new  HttpResource(url)                                                  .ThatAccepts("application/xml")                                                  .Get();            Assert.That(response.StatusCode,  Is.EqualTo(200));          AssertHasXPath(response.Body,  "//productCode");          AssertHasXPath(response.Body,  "//description");          AssertHasXPath(response.Body,  "//monthlyCharge");          AssertNumeric(ValueFor(response.Body,  "//monthlyCharge"));   }  
  42. 42. use bounded contexts to control complexity
  43. 43. Rates! CSR UI! Provisioning!Finance! Billing! Invoicing! Marketing /! Website! Product! Catalog!
  44. 44. data rationalization
  45. 45. Conway’s Law Organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations In every organization there will always be one person who knows what is going on. This person must be fired.
  46. 46. product! finance! invoice! billing! create! record event! get events! augment! augment! augment!
  47. 47. twitter:@BrandonByars! http://martinfowler.com/articles/enterpriseREST.html!
  48. 48. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/constraints -api-rest-integration

×