SlideShare a Scribd company logo
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Consumer Driven Contracts and
Your Microservice Architecture
By Marcin Grzejszczak
@mgrzejszczak
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
About me
• Spring Cloud developer
• Working mostly on Spring Cloud Sleuth
and Spring Cloud Contract
• Automation freak
Twitter: @mgrzejszczak
Blog: http://toomuchcoding.com
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Agenda
• Introduction
• Demo
• Summary
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Introduction
• Producer
– service that exposes an API
• Consumer
– service that consumes the API of the producer
• Contract
– agreement between producer and consumer how the API will look like
• Consumer Driven Contracts
– approach where the consumer drives the changes of the API of the
producer
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
What are we going to code?
• Consumer
– service that gets beer requests
– has to ask another service if the client can get the beer
• Producer
– service that checks if the client is old enough to buy beer
• Feature
– if the user is too young - the beer will not be sold
– otherwise the beer will be granted
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
DEMO
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Summary
With Spring Cloud Contract and Consumer Driven Contracts:
• we’ve created an API that suits the consumer and the producer
• expectations were defined by readable contracts that were tested against
the producer
• producer stubs can be reused by consumers
• starting and setting stubs is fully automated
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Summary - Consumer flow 1
Consumer
• starts TDD - writes the test for the feature
• clones producer code to change the API locally
• in the cloned producer code converts contracts into stubs and installs them locally
• in the consumer code turns Stub Runner to offline mode
• configures Stub Runner to download stubs of the producer
• red - green - refactor on the API and tests
• repeats the process until the tests are green and API acceptable
• files a PR to the producer with the contract proposal
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Summary - Producer flow
Producer
• takes over the PR
• writes the missing implementation that will make the autogenerated tests pass
• merges PR and deploys the JARs with the app and the stubs
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Summary - Consumer flow 2
Consumer
• switches off the Stub Runner’s offline mode once the producer uploads the
stubs
• configure Stub Runner by providing the URL to a repo with stubs
• will have its test broken if the producer makes any breaking changes of the
API
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Why use Spring Cloud Contract Verifier?
• Possibility to do CDC with messaging
• Clear and easy to use, statically typed DSL
• Automatic generation of tests from the defined Contract
• Stub Runner functionality - the stubs are automatically downloaded at runtime
from Nexus / Artifactory
• Spring Cloud integration - no discovery service is needed for integration tests
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
QUESTIONS?
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
● http://martinfowler.com/articles/consumerDrivenContracts.html - article about
Consumer Driven Contracts by Ian Robinson
● https://github.com/marcingrzejszczak/springone-cdc-client - code for the
client side of the presented example
● https://github.com/marcingrzejszczak/springone-cdc-server - code for the
server side of the presented example
● https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html -
documentation of the Spring Cloud Contract project
Thank you!
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Learn More. Stay Connected.
https://gitter.im/spring-cloud/spring-cloud-contract
@springcentral
spring.io/blog
@pivotal
pivotal.io/blog
@pivotalcf
http://engineering.pivotal.io

More Related Content

PDF
Do you think you're doing microservice architecture? What about infrastructur...
PDF
4Developers 2015: Do you think you're doing microservice architecture? - Marc...
PDF
Microservices pattern language (microxchg microxchg2016)
PPTX
Reactive Data Access with Spring Data
PPTX
Consumer Driven Contracts and Your Microservice Architecture
PPTX
The journey to DevOps: What I learned after leading transformation at 2 Enter...
PDF
Extending the Platform
PDF
DESIGN THE PRIORITY, PERFORMANCE 
AND UX
Do you think you're doing microservice architecture? What about infrastructur...
4Developers 2015: Do you think you're doing microservice architecture? - Marc...
Microservices pattern language (microxchg microxchg2016)
Reactive Data Access with Spring Data
Consumer Driven Contracts and Your Microservice Architecture
The journey to DevOps: What I learned after leading transformation at 2 Enter...
Extending the Platform
DESIGN THE PRIORITY, PERFORMANCE 
AND UX

What's hot (19)

PPTX
Accelerating the Consumption of APIs Built on Cloud Foundry
PDF
SpringOnePlatform2017 recap
ODP
New Amazing Things about AngularJS 2.0
PDF
Beyond API Spray & Pray: Developer Portals in Digital Transformation
PDF
Spring Cloud Gateway - Ryan Baxter
PPTX
The Reality of DIY Kubernetes vs. PKS
PDF
Deliver Your Service on PKS
PPTX
Spring Cloud on Kubernetes
PDF
Cloud Configuration Ecosystem at Intuit
PDF
New in Spring Framework 5.0: Functional Web Framework
PDF
Cloud Native Java with Spring Cloud Services
PDF
React vs angular which front end framework should you choose and why
PDF
Spring Cloud Gateway - Ryan Baxter
PDF
The end of polling : why and how to transform a REST API into a Data Streamin...
PPTX
Securing Pivotal Platform at Prime Therapeutics
PDF
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
PPTX
Adobe CQ at LinkedIn Meetup February 2014
PPTX
React vs Angular
PPTX
More Devs, No Problems: Enabling Self-Service Access to Kubernetes
Accelerating the Consumption of APIs Built on Cloud Foundry
SpringOnePlatform2017 recap
New Amazing Things about AngularJS 2.0
Beyond API Spray & Pray: Developer Portals in Digital Transformation
Spring Cloud Gateway - Ryan Baxter
The Reality of DIY Kubernetes vs. PKS
Deliver Your Service on PKS
Spring Cloud on Kubernetes
Cloud Configuration Ecosystem at Intuit
New in Spring Framework 5.0: Functional Web Framework
Cloud Native Java with Spring Cloud Services
React vs angular which front end framework should you choose and why
Spring Cloud Gateway - Ryan Baxter
The end of polling : why and how to transform a REST API into a Data Streamin...
Securing Pivotal Platform at Prime Therapeutics
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
Adobe CQ at LinkedIn Meetup February 2014
React vs Angular
More Devs, No Problems: Enabling Self-Service Access to Kubernetes
Ad

Similar to Consumer Driven Contracts and Your Microservice Architecture (20)

PDF
Spring Cloud Contract And Your Microservice Architecture
PDF
Consumer Driven Contracts and Your Microservice Architecture
PDF
Consumer Driven Contracts To Enable API Evolution @Geecon
PDF
Consumer Driven Contracts and Your Microservice Architecture
PPTX
Consumer Driven Contracts for microservices
PDF
Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
PDF
TDD for Microservices
PPTX
Consumer driven contracts in java world
PDF
Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG
PDF
Consumer Driven Contracts - 4Developers 2015
PDF
4Developers 2015: Stick to the rules - Consumer Driven Contracts - Marcin Grz...
PPTX
[TestWarez 2017] Behavior Driven Development in a complex environment - Consu...
PDF
Consumer driven contract testing
PDF
Microservices: Consumer Driven Contracts in Practice
PDF
Square Pegs, Square Holes: CI/CD That Fits
PPTX
Coordinating Micro-Services with Spring Cloud Contract
PDF
SpringOne 2016 in a nutshell
PDF
Consumer-Driven Contract Testing With Postman
PDF
Stick to the rules - Consumer Driven Contracts. 2015.07 Confitura
PDF
Cloud Customer Architecture for API Management
Spring Cloud Contract And Your Microservice Architecture
Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts To Enable API Evolution @Geecon
Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts for microservices
Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
TDD for Microservices
Consumer driven contracts in java world
Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG
Consumer Driven Contracts - 4Developers 2015
4Developers 2015: Stick to the rules - Consumer Driven Contracts - Marcin Grz...
[TestWarez 2017] Behavior Driven Development in a complex environment - Consu...
Consumer driven contract testing
Microservices: Consumer Driven Contracts in Practice
Square Pegs, Square Holes: CI/CD That Fits
Coordinating Micro-Services with Spring Cloud Contract
SpringOne 2016 in a nutshell
Consumer-Driven Contract Testing With Postman
Stick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Cloud Customer Architecture for API Management
Ad

More from Marcin Grzejszczak (12)

PDF
Continuous Deployment of your Application @jSession#5
PDF
Continuous Deployment of your Application @JUGtoberfest
PDF
Continuous Deployment To The Cloud @DevoxxPL 2017
PDF
Continuous Deployment To The Cloud
PDF
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
PDF
Microservices Tracing With Spring Cloud and Zipkin @Szczecin JUG
PDF
Microservices Tracing with Spring Cloud and Zipkin (devoxx)
PDF
Microservices Tracing With Spring Cloud and Zipkin @CybercomDEV
PDF
Microservices Tracing with Spring Cloud and Zipkin
PDF
Spring Cloud’s Groovy
PDF
Microservices - enough with theory, let's do some code @Geecon Prague 2015
PDF
Introduction to Groovy runtime metaprogramming and AST transforms
Continuous Deployment of your Application @jSession#5
Continuous Deployment of your Application @JUGtoberfest
Continuous Deployment To The Cloud @DevoxxPL 2017
Continuous Deployment To The Cloud
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
Microservices Tracing With Spring Cloud and Zipkin @Szczecin JUG
Microservices Tracing with Spring Cloud and Zipkin (devoxx)
Microservices Tracing With Spring Cloud and Zipkin @CybercomDEV
Microservices Tracing with Spring Cloud and Zipkin
Spring Cloud’s Groovy
Microservices - enough with theory, let's do some code @Geecon Prague 2015
Introduction to Groovy runtime metaprogramming and AST transforms

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Machine learning based COVID-19 study performance prediction
PDF
Electronic commerce courselecture one. Pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Approach and Philosophy of On baking technology
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
KodekX | Application Modernization Development
Programs and apps: productivity, graphics, security and other tools
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The Rise and Fall of 3GPP – Time for a Sabbatical?
Machine learning based COVID-19 study performance prediction
Electronic commerce courselecture one. Pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Spectroscopy.pptx food analysis technology
MYSQL Presentation for SQL database connectivity
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Approach and Philosophy of On baking technology
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
The AUB Centre for AI in Media Proposal.docx
KodekX | Application Modernization Development

Consumer Driven Contracts and Your Microservice Architecture

  • 1. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Consumer Driven Contracts and Your Microservice Architecture By Marcin Grzejszczak @mgrzejszczak
  • 2. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ About me • Spring Cloud developer • Working mostly on Spring Cloud Sleuth and Spring Cloud Contract • Automation freak Twitter: @mgrzejszczak Blog: http://toomuchcoding.com
  • 3. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Agenda • Introduction • Demo • Summary
  • 4. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Introduction • Producer – service that exposes an API • Consumer – service that consumes the API of the producer • Contract – agreement between producer and consumer how the API will look like • Consumer Driven Contracts – approach where the consumer drives the changes of the API of the producer
  • 5. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What are we going to code? • Consumer – service that gets beer requests – has to ask another service if the client can get the beer • Producer – service that checks if the client is old enough to buy beer • Feature – if the user is too young - the beer will not be sold – otherwise the beer will be granted
  • 6. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ DEMO
  • 7. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Summary With Spring Cloud Contract and Consumer Driven Contracts: • we’ve created an API that suits the consumer and the producer • expectations were defined by readable contracts that were tested against the producer • producer stubs can be reused by consumers • starting and setting stubs is fully automated
  • 8. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Summary - Consumer flow 1 Consumer • starts TDD - writes the test for the feature • clones producer code to change the API locally • in the cloned producer code converts contracts into stubs and installs them locally • in the consumer code turns Stub Runner to offline mode • configures Stub Runner to download stubs of the producer • red - green - refactor on the API and tests • repeats the process until the tests are green and API acceptable • files a PR to the producer with the contract proposal
  • 9. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Summary - Producer flow Producer • takes over the PR • writes the missing implementation that will make the autogenerated tests pass • merges PR and deploys the JARs with the app and the stubs
  • 10. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Summary - Consumer flow 2 Consumer • switches off the Stub Runner’s offline mode once the producer uploads the stubs • configure Stub Runner by providing the URL to a repo with stubs • will have its test broken if the producer makes any breaking changes of the API
  • 11. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Why use Spring Cloud Contract Verifier? • Possibility to do CDC with messaging • Clear and easy to use, statically typed DSL • Automatic generation of tests from the defined Contract • Stub Runner functionality - the stubs are automatically downloaded at runtime from Nexus / Artifactory • Spring Cloud integration - no discovery service is needed for integration tests
  • 12. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ QUESTIONS?
  • 13. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ ● http://martinfowler.com/articles/consumerDrivenContracts.html - article about Consumer Driven Contracts by Ian Robinson ● https://github.com/marcingrzejszczak/springone-cdc-client - code for the client side of the presented example ● https://github.com/marcingrzejszczak/springone-cdc-server - code for the server side of the presented example ● https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html - documentation of the Spring Cloud Contract project Thank you!
  • 14. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Learn More. Stay Connected. https://gitter.im/spring-cloud/spring-cloud-contract @springcentral spring.io/blog @pivotal pivotal.io/blog @pivotalcf http://engineering.pivotal.io