SlideShare a Scribd company logo
Consumer Driven Contracts for
Microservices
By Reshmi Krishna By Vinay Upadhya
@reshmi9k @vinayu
About Us
Reshmi Krishna
● Software Engineer
● Platform Architect, Pivotal Cloud Foundry
● Women In Tech Community Member
Twitter : @reshmi9k
MeetUp : Cloud-Native-New-York
Vinay Upadhya
● Software Engineer
● Platform Architect, Pivotal Cloud Foundry
● Application Architecture Evangelist
Twitter : @vinayu
Agenda
What are Consumer Driven Contracts?
What problems are we trying to solve?
Spring Cloud Contract for microservices
Demo
What are Consumer Driven Contracts?
Internal
Marketing
App
External
Reseller
App
Product
Search
Service
A
P
I
{ catalogid, name,
price,
manufacturer }
{ catalogid,
name, price }
Product Schema
{ catalogid, name, price,
manufacturer,
inStock }
Producer
Contract
Expectation
Consumer
Contract
Consumer Driven
Contract
What are Consumer Driven Contracts ( CDC )
Not a new concept but becoming more prevalent in today’s world of
microservices.
It is a pattern for evolving services and their API’s without breaking
backward or forward compatibility.
CDC driven testing is TDD applied at an architectural level of the project.
What problems are we trying to solve?
1. Provide a framework for consumers to set
expectations with consumer contracts and
drive the producer API.
2. Producer test lifecycle includes validating
consumer contracts.
3. Provide reusable producer stubs for
consumers to use in their integration tests.
4. Minimize E2E integration tests.
Spring Cloud Contract
Spring Cloud Contract provides support for CDC and service schemas in Spring Apps.
Being part of Spring Cloud it can help stub out Spring Cloud components like Eureka, Consul
etc.
Comprised of three main projects :-
Spring Cloud Contract Verifier : Library on server side to test if the server isn’t breaking any
consumer contracts.
Spring Cloud Contract Wiremock : Wrapper around wiremock to help start stubs with
wiremock json stubs.
Spring Cloud Contract Stub Runner : Helper library to pull stubs from maven and run them
What is a contract?
Demo
I want to login Can Reshmi/123 login ?
YES !!!!
OK
Demo
I want to login Can Vinay/321 login ?
No !!!!
NOT_OKAY
Typical CDC Flow
Consumer Phase 1 Producer Phase Consumer Phase 2
Consumer
Offline Work
Producer
Implementing
Feature
Consumer
Online Work
Consumer Flow 1 (Login Client)
Start TDD - writes the test for the feature
Write the missing implementation
Clone the Producer (LoginServerService) repository locally
Define the contract locally in the repo of Producer
Add the Spring Cloud Contract Verifier plugin
Run the integration tests
Producer Flow (Login Server)
Take over the PR
Write the missing implementation that will make the autogenerated tests pass
Merge PR and deploys the JARs with the app and the stubs
Consumer Flow 2 (Login Client)
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
Demo : Add additional parameter to login
Login Validate(UN,PWD,AC)
Response
Response
Resources
Docs : https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html
MeetUp Demo : https://github.com/reshmik/spring-cloud-contract-login-demo.git
Consumer Driven Contracts (MarcinGrzejszczak) : http://www.slideshare.net/MarcinGrzejszczak/consumer-driven-contracts-
and-your-microservice-architecture-67641511
More Samples : https://github.com/spring-cloud/spring-cloud-contract/tree/1.0.x/samples
Talk to the SpringCloudContract Team : https://gitter.im/spring-cloud/spring-cloud-contract

More Related Content

PPTX
MACRA and the Merit-Based Incentive Payment System (MIPS)
PPTX
Wearable biosensors
PPTX
Radio Frequency Identification
PDF
ISP part 3
PDF
WSO2 API Manager 2.0 - Overview
PPTX
Vehicle Speed detecter By PRAGYA AGARWAL
PDF
Relationship Between Thailand's Official Information Act and Personal Data Pr...
PDF
IOT-Based Wild Animal Intrusion Detection System
MACRA and the Merit-Based Incentive Payment System (MIPS)
Wearable biosensors
Radio Frequency Identification
ISP part 3
WSO2 API Manager 2.0 - Overview
Vehicle Speed detecter By PRAGYA AGARWAL
Relationship Between Thailand's Official Information Act and Personal Data Pr...
IOT-Based Wild Animal Intrusion Detection System

Viewers also liked (20)

PDF
Implementing microservices tracing with spring cloud and zipkin (spring one)
PDF
Consumer Driven Contracts and Your Microservice Architecture
PDF
Microservices: Consumer Driven Contracts in Practice
PDF
Consumer Driven Contracts and Your Microservice Architecture
PDF
Spring Cloud Contract And Your Microservice Architecture
PPTX
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
PDF
Lattice: A Cloud-Native Platform for Your Spring Applications
PDF
Agile Development with OSGi
PDF
Electrolux Capital Markets Day 2013 - Presentation Keith McLoughlin, CEO
PDF
What is this "docker"
PDF
Gradle起步走: 以CLI Application為例 @ JCConf 2014
PDF
Reactive Fault Tolerant Programming with Hystrix and RxJava
PPTX
从玩具到生产 - Cloud Foundry 上海峰会2015年
PPTX
Emirates
PDF
Establish The Core of Cloud Computing Application by Using Hazelcast (Chinese)
PPTX
台中青商微講堂 2015 雲端工具活用術 by Lala
PDF
Honey's Data Dinner#13 跨領域專案開發經驗談(User Story Mapping)
PDF
我的敏捷测试宣言(Agile Testing Manifesto)
PDF
Consumer Driven Contracts (DDD Perth 2016)
PDF
SSH & the City. From measuring societal impact to mapping social engagement
Implementing microservices tracing with spring cloud and zipkin (spring one)
Consumer Driven Contracts and Your Microservice Architecture
Microservices: Consumer Driven Contracts in Practice
Consumer Driven Contracts and Your Microservice Architecture
Spring Cloud Contract And Your Microservice Architecture
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
Lattice: A Cloud-Native Platform for Your Spring Applications
Agile Development with OSGi
Electrolux Capital Markets Day 2013 - Presentation Keith McLoughlin, CEO
What is this "docker"
Gradle起步走: 以CLI Application為例 @ JCConf 2014
Reactive Fault Tolerant Programming with Hystrix and RxJava
从玩具到生产 - Cloud Foundry 上海峰会2015年
Emirates
Establish The Core of Cloud Computing Application by Using Hazelcast (Chinese)
台中青商微講堂 2015 雲端工具活用術 by Lala
Honey's Data Dinner#13 跨領域專案開發經驗談(User Story Mapping)
我的敏捷测试宣言(Agile Testing Manifesto)
Consumer Driven Contracts (DDD Perth 2016)
SSH & the City. From measuring societal impact to mapping social engagement
Ad

Similar to Consumer Driven Contracts for microservices (20)

PDF
TDD for Microservices
PDF
Transform Digital Business with DevOps
PDF
Speed Wins: From Kafka to APIs in Minutes
PPTX
Consumer driven contracts in java world
PDF
Continuous delivery with Spring Cloud Pipelines Case Study
PPTX
Continuous Delivery with Spring Cloud Pipelines: Case study. - Lublin JUG
PPTX
DevOps: Age Of CI/CD
PPTX
RTP Bluemix Meetup April 20th 2016
PDF
Building Real-Time Gen AI Applications with SingleStore and Confluent
PPTX
Wading through treacle? Escape the integration syrup with contract tests
PDF
MACHINE LEARNING AUTOMATIONS PIPELINE WITH CI/CD
PDF
DIY Transparent Release Management_2024_07.pdf
PPTX
Microsoft DevOps Solution - DevOps
PPTX
UrbanCode Deploy course and product overview slides
PDF
Cloud-Native Fundamentals: Accelerating Development with Continuous Integration
PDF
The Reality of Managing Microservices in Your CD Pipeline
PPTX
Overview
PDF
OSSF 2018 - Brandon Jung of GitLab - Is Your DevOps 'Tool Tax' Weighing You D...
PDF
Citi Tech Talk: Messaging Modernization
PDF
Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)
TDD for Microservices
Transform Digital Business with DevOps
Speed Wins: From Kafka to APIs in Minutes
Consumer driven contracts in java world
Continuous delivery with Spring Cloud Pipelines Case Study
Continuous Delivery with Spring Cloud Pipelines: Case study. - Lublin JUG
DevOps: Age Of CI/CD
RTP Bluemix Meetup April 20th 2016
Building Real-Time Gen AI Applications with SingleStore and Confluent
Wading through treacle? Escape the integration syrup with contract tests
MACHINE LEARNING AUTOMATIONS PIPELINE WITH CI/CD
DIY Transparent Release Management_2024_07.pdf
Microsoft DevOps Solution - DevOps
UrbanCode Deploy course and product overview slides
Cloud-Native Fundamentals: Accelerating Development with Continuous Integration
The Reality of Managing Microservices in Your CD Pipeline
Overview
OSSF 2018 - Brandon Jung of GitLab - Is Your DevOps 'Tool Tax' Weighing You D...
Citi Tech Talk: Messaging Modernization
Four Steps Toward a Safer Continuous Delivery Practice (Hint: Add Monitoring)
Ad

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Cloud computing and distributed systems.
Unlocking AI with Model Context Protocol (MCP)
MIND Revenue Release Quarter 2 2025 Press Release
Network Security Unit 5.pdf for BCA BBA.
Empathic Computing: Creating Shared Understanding
Diabetes mellitus diagnosis method based random forest with bat algorithm
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Spectroscopy.pptx food analysis technology
Dropbox Q2 2025 Financial Results & Investor Presentation
sap open course for s4hana steps from ECC to s4
Cloud computing and distributed systems.

Consumer Driven Contracts for microservices

  • 1. Consumer Driven Contracts for Microservices By Reshmi Krishna By Vinay Upadhya @reshmi9k @vinayu
  • 2. About Us Reshmi Krishna ● Software Engineer ● Platform Architect, Pivotal Cloud Foundry ● Women In Tech Community Member Twitter : @reshmi9k MeetUp : Cloud-Native-New-York Vinay Upadhya ● Software Engineer ● Platform Architect, Pivotal Cloud Foundry ● Application Architecture Evangelist Twitter : @vinayu
  • 3. Agenda What are Consumer Driven Contracts? What problems are we trying to solve? Spring Cloud Contract for microservices Demo
  • 4. What are Consumer Driven Contracts? Internal Marketing App External Reseller App Product Search Service A P I { catalogid, name, price, manufacturer } { catalogid, name, price } Product Schema { catalogid, name, price, manufacturer, inStock } Producer Contract Expectation Consumer Contract Consumer Driven Contract
  • 5. What are Consumer Driven Contracts ( CDC ) Not a new concept but becoming more prevalent in today’s world of microservices. It is a pattern for evolving services and their API’s without breaking backward or forward compatibility. CDC driven testing is TDD applied at an architectural level of the project.
  • 6. What problems are we trying to solve? 1. Provide a framework for consumers to set expectations with consumer contracts and drive the producer API. 2. Producer test lifecycle includes validating consumer contracts. 3. Provide reusable producer stubs for consumers to use in their integration tests. 4. Minimize E2E integration tests.
  • 7. Spring Cloud Contract Spring Cloud Contract provides support for CDC and service schemas in Spring Apps. Being part of Spring Cloud it can help stub out Spring Cloud components like Eureka, Consul etc. Comprised of three main projects :- Spring Cloud Contract Verifier : Library on server side to test if the server isn’t breaking any consumer contracts. Spring Cloud Contract Wiremock : Wrapper around wiremock to help start stubs with wiremock json stubs. Spring Cloud Contract Stub Runner : Helper library to pull stubs from maven and run them
  • 8. What is a contract?
  • 9. Demo I want to login Can Reshmi/123 login ? YES !!!! OK
  • 10. Demo I want to login Can Vinay/321 login ? No !!!! NOT_OKAY
  • 11. Typical CDC Flow Consumer Phase 1 Producer Phase Consumer Phase 2 Consumer Offline Work Producer Implementing Feature Consumer Online Work
  • 12. Consumer Flow 1 (Login Client) Start TDD - writes the test for the feature Write the missing implementation Clone the Producer (LoginServerService) repository locally Define the contract locally in the repo of Producer Add the Spring Cloud Contract Verifier plugin Run the integration tests
  • 13. Producer Flow (Login Server) Take over the PR Write the missing implementation that will make the autogenerated tests pass Merge PR and deploys the JARs with the app and the stubs
  • 14. Consumer Flow 2 (Login Client) 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
  • 15. Demo : Add additional parameter to login Login Validate(UN,PWD,AC) Response Response
  • 16. Resources Docs : https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html MeetUp Demo : https://github.com/reshmik/spring-cloud-contract-login-demo.git Consumer Driven Contracts (MarcinGrzejszczak) : http://www.slideshare.net/MarcinGrzejszczak/consumer-driven-contracts- and-your-microservice-architecture-67641511 More Samples : https://github.com/spring-cloud/spring-cloud-contract/tree/1.0.x/samples Talk to the SpringCloudContract Team : https://gitter.im/spring-cloud/spring-cloud-contract