SlideShare a Scribd company logo
Consumer Driven Contracts
in Java world
About myself
● Application Architect @Thomas
Cook
● Tech Lead - Platformers team
● +9 years Java
Content
● Consumer Driven Contracts - general concepts;
● Consumer Driven Contracts - hygiene for APIs;
● Spring Cloud Contracts;
● Pact;
● Demo.
Monolith: Past expectation
Monolith: Today’s Reality
Conclusion...
We need microservices!!!
They will be small and tidy
Well, yes, but....
And in a year we will see something like:
Conclusion...
Microservices require
more attention to
standards
Will your cool, modern microservices bring any
value in terms of time-to-market...
Will your cool, modern microservices bring any
value in terms of time-to-market...
...without agreements/contracts between them?
In terms of Quality Attributes:
It’s never enough to comply with Runtime
attributes
when your Design attributes are not in order.
We started with API Documentation at the
time of decomposing our monolith
But as time goes by we have come to realize
it’s not enough...
Because our
documented API
looks more like this:
And our expectation was a system where
services know about each other
Standards are required for things like monitoring,
logging, backward compatibility, and API contracts.
API Contracts
Lean principle:
A service is of value to the business only to the
extent it is consumed.
https://martinfowler.com/articles/consumerDrivenContracts.html
Make sure the Contracts can be imposed
Set of rules and
technologies that should be
implemented and adopted
on both sides.
Do it as early as you can!
Option 1: testing a chain of services without
contracts
You can go the hard way and deploy all
microservices at once to test them
together
Drawbacks:
● Long cycle;
● Full Infrastructure required;
● Hard to debug;
● Very late feedback;
Option 2: Mock other microservices in unit /
integration tests
Drawbacks:
● It simple has nothing to do with
the reality if you do it in isolation.
Postel's law
“Be conservative in what you do, be liberal in
what you accept from others
(often reworded as "Be conservative in what you
send, be liberal in what you accept").”
Doesn’t Contract couple our services?
Enter Consumer Driven Contracts
Producer should have a contract for every
specific Consumer
It means that potentially there can be multiple
contracts, a separate one for each Consumer,
Contract visualisation:
API:
get: customers/{id}
post: customers/
put: customers/{id}
delete: customers/{id}
get: customers/{id}/bookings/{id}
post: customers/{id}/bookings/
delete: customers/{id}/bookings/{id}Producer
API:
get: customers/{id}
post: customers/
put: customers/{id}
delete: customers/{id}
get: customers/{id}/bookings/{id}
post: customers/{id}/bookings/
delete: customers/{id}/bookings/{id}
Consumer 1
Producer
get: customers/{id}
post: customers/
put: customers/{id}
Contract visualisation:
API:
get: customers/{id}
post: customers/
put: customers/{id}
delete: customers/{id}
get: customers/{id}/bookings/{id}
post: customers/{id}/bookings/
delete: customers/{id}/bookings/{id}
Consumer 1
Producer
Consumer 2
get: customers/{id}
post: customers/
put: customers/{id}
put: customers/{id}
delete: customers/{id}
Contract visualisation:
API:
get: customers/{id}
post: customers/
put: customers/{id}
delete: customers/{id}
get: customers/{id}/bookings/{id}
post: customers/{id}/bookings/
delete: customers/{id}/bookings/{id}
Consumer 1
Producer
Consumer 2
get: customers/{id}
post: customers/
put: customers/{id}
put: customers/{id}
delete: customers/{id}
Consumer 3
get: customers/
{id}/bookings/{id}
post: customers/{id}/
bookings/
Contract visualisation:
API:
get: customers/{id}
post: customers/
put: customers/{id}
delete: customers/{id}
get: customers/{id}/bookings/{id}
post: customers/{id}/bookings/
delete: customers/{id}/bookings/{id}
Consumer 1
Producer
Consumer 2
get: customers/{id}
post: customers/
put: customers/{id}
put: customers/{id}
delete: customers/{id}
Consumer 3
get: customers/
{id}/bookings/{id}
post: customers/{id}/
bookings/
Overlapping part of 2 contracts
Contract visualisation:
API:
get: customers/{id}
post: customers/
put: customers/{id}
delete: customers/{id}
get:
customers/{id}/bookings/{id}
post:
customers/{id}/bookings/
Consumer 1
Producer
Consumer 2
get: customers/{id}
post: customers/
put: customers/{id}
put: customers/{id}
delete: customers/{id}
Consumer 3
get: customers/
{id}/bookings/{id}
post: customers/{id}/
bookings/
Overlapping part of 2 contracts
Completely independent contract
delete: customers/{id}/bookings/{id}
Contract visualisation:
API:
get: customers/{id}
post: customers/
put: customers/{id}
delete: customers/{id}
get:
customers/{id}/bookings/{id}
post:
customers/{id}/bookings/
Consumer 1
Producer
Consumer 2
get: customers/{id}
post: customers/
put: customers/{id}
put: customers/{id}
delete: customers/{id}
Consumer 3
get: customers/
{id}/bookings/{id}
post: customers/{id}/
bookings/
Overlapping part of 2 contracts
Completely independent contract
delete:
customers/{id}/bookings/{id}
No in use
Contract visualisation:
Some parts of the APIs might not be used and
will not impact anyone. They might either be in a
state of active development or about to be
decommissioned
Demystification
These tests are not component tests. They do not
test the behaviour of the service deeply but that
the inputs and outputs of service calls contain
required attributes.
Contract: specific scenario rather than schema
Their main advantage is that they are fast and
reliable.
What tools are there for Java devs?
There are 2 main options:
1. Spring Cloud Contracts;
2. Pact.
Spring Cloud Contracts
● Spring Cloud Contract Verifier - the
producer side;
● Spring Cloud Contract Stub Runner - the
consumer side
Spring Cloud Contracts: Contract Verifier
Shipped with Contract Definition Language
(DSL) written in Groovy or YAML.
Spring Cloud Contract Verifier provides:
● Alignment between stubs and actual
implementation;
● Acceptance test driven development;
● Immediate visibility of contracts on both sides;
● Autogenerated boilerplate tests.
Spring Cloud Contracts: Contract Stub Runner
● Fetches the stubs of the producer;
● Runs tests against the stubs.
Spring Cloud Contracts: Contract Definition
Language
There’s more if you read into specs:
● Groovy DSL
● YAML
Spring Cloud Contracts: Contract Definition
Language
There’s more if you read into specs:
● Groovy DSL
● YAML
● Pact JSON
● Spring Rest Docs
Spring Cloud Contracts: Contract Definition
Language
Spring Cloud Contracts - catchline
“Spring Cloud Contract Verifier moves TDD to
the level of software architecture.”
SCC guarantees:
● Stubs reliability: generated on successful test
execution.
● Stubs reusability: packed in a separate artifact
with a stub classifier.
Spring Cloud Contract: look inside
Server / Producer side utilization:
Maven/gradle plugin + verifier
Server / Producer side: contract DSL
Groovy YAML
package contracts
import org.springframework...t
Contract.make {
request {
method 'PUT'
url '/bookings/4'
body("""
{
"id": 4,
"destination": "USA",
….
}
response {
status 204
request:
method: PUT
url: /bookings/4
body:
id: 4,
destination: "USA"
response:
status: 204
Server / Producer side: base class
<baseClassForTests>....api.controllers.BookingControllerImplTest</...>
Server / Producer side: base class
The responsibility to initialising your MockMvc is on you:
java.lang.IllegalStateException: You haven't configured a MockMVC
instance. You can do this statically
RestAssuredMockMvc.mockMvc(..)
RestAssuredMockMvc.standaloneSetup(..);
RestAssuredMockMvc.webAppContextSetup(..);
or using the DSL:
given().
mockMvc(..). ..
Server / Producer side: producer stubs
Spring Cloud Contract Verifier will convert the contracts into an HTTP
server stub definitions(Wiremock mapping jsons).
Demo time!
● Run Producer tests;
● Spring-cloud-contract-maven-plugin options;
● Run Consumer tests;
● Groovy DSL vs YAML;
● Add stateful behaviour(real MySql instance) for visibility;
● Non-binary storage(git);
● Explain stubrunner yaml property and how it impacts tests;
● Wiremock scenarios;
● produce(), consume() and matchers;
● execute() with custom utility methods;
● Integration with the rest of Spring Cloud.
Pact
The cross-language distributed
contract testing framework.
Pact: language support
● Ruby Pact
● JVM Pact and Scala-Pact
● .NET Pact
● JS Pact
● Go Pact (there is also a v1.1 native Pact Go)
● Swift / Objective-C Pact
● Python
● PHP
Pact: objective
The requirements of the consumer(s)
are used to drive the features of the
provider.
Pact: diagram
Consumer
● Specifies the contracts;
● Generates the pact files;
● Push them into Pact Broker
Pact: diagram
Consumer
● Specifies the contracts;
● Generates the pact files;
● Push them into Pact Broker
Pact Broker
● Stores pact contracts;
● Integrates into CI tools.
Pact: diagram
Consumer
● Specifies the contracts;
● Generates the pact files;
● Push them into Pact Broker
Pact Broker
● Stores pact contracts;
● Integrates into CI tools.
Producer
● Implement a service
according to Consumer
specs.
Demo time!
● Pact core concepts: State, Broker, Verification;
● Versioning;
● Pact extension for Spring Cloud Contracts;
Useful links
● https://github.com/spring-cloud-samples/spring-cloud-contract-samples
● https://github.com/DiUS/pact-workshop-jvm
● https://github.com/DiUS/pact-jvm
● https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven
Summary
Use API Contracts ?: Adopt a design first approach ?: Document
your APIs ?: You are hopeless
Thank you!
Mail: yura.v.nosenko@gmail.com
Linkedin: https://www.linkedin.com/in/yuranos/
Github example:
https://github.com/yuranos/raml-based-producer-application,
https://github.com/yuranos/raml-based-consumer-application
(consumer_driven_contracts branches)

More Related Content

PPTX
Contract based testing
PDF
Building modular monoliths that could scale to microservices (only if they ne...
PDF
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
PPTX
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
PPTX
Consumer Driven Contracts and Your Microservice Architecture
PDF
Building Modular monliths that could scale to microservices (only if they nee...
PDF
Next Generation Hybrid Applications with Qt - presentation for SEE 2009
PPTX
DDD meets CQRS and event sourcing
Contract based testing
Building modular monoliths that could scale to microservices (only if they ne...
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Consumer-driven contracts: avoid microservices integration hell! (LondonCD - ...
Consumer Driven Contracts and Your Microservice Architecture
Building Modular monliths that could scale to microservices (only if they nee...
Next Generation Hybrid Applications with Qt - presentation for SEE 2009
DDD meets CQRS and event sourcing

Similar to Consumer driven contracts in java world (20)

PDF
Consumer Driven Contracts and Your Microservice Architecture
PDF
Consumer Driven Contracts and Your Microservice Architecture
PDF
Consumer contract testing
PDF
Microservices: Consumer Driven Contracts in Practice
PDF
Consumer-Driven Contract Testing
PDF
Spring Cloud Contract And Your Microservice Architecture
PPTX
Coordinating Micro-Services with Spring Cloud Contract
PDF
Consumer Driven Contracts and Your Microservice Architecture
PDF
Consumer Driven Contracts To Enable API Evolution @Geecon
PPTX
Collaborative Contract Driven Development
PDF
Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
PPTX
Contract driven development
PPTX
Contract testing: Beyond API functional testing
PDF
Move fast and consumer driven contract test things
PDF
TDD for Microservices
PDF
SpringOne 2016 in a nutshell
PDF
Contract Testing
PDF
SOA Latam 2015
PDF
Contract testing | Евгений Кузьмин | CODEiD
PDF
SGCE 2015 REST APIs
Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice Architecture
Consumer contract testing
Microservices: Consumer Driven Contracts in Practice
Consumer-Driven Contract Testing
Spring Cloud Contract And Your Microservice Architecture
Coordinating Micro-Services with Spring Cloud Contract
Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts To Enable API Evolution @Geecon
Collaborative Contract Driven Development
Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
Contract driven development
Contract testing: Beyond API functional testing
Move fast and consumer driven contract test things
TDD for Microservices
SpringOne 2016 in a nutshell
Contract Testing
SOA Latam 2015
Contract testing | Евгений Кузьмин | CODEiD
SGCE 2015 REST APIs
Ad

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Digital Strategies for Manufacturing Companies
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
AI in Product Development-omnex systems
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
ai tools demonstartion for schools and inter college
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
history of c programming in notes for students .pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
medical staffing services at VALiNTRY
PPTX
Odoo POS Development Services by CandidRoot Solutions
L1 - Introduction to python Backend.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Digital Strategies for Manufacturing Companies
wealthsignaloriginal-com-DS-text-... (1).pdf
Softaken Excel to vCard Converter Software.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
AI in Product Development-omnex systems
VVF-Customer-Presentation2025-Ver1.9.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
How to Choose the Right IT Partner for Your Business in Malaysia
ai tools demonstartion for schools and inter college
CHAPTER 2 - PM Management and IT Context
history of c programming in notes for students .pptx
Operating system designcfffgfgggggggvggggggggg
Design an Analysis of Algorithms I-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
medical staffing services at VALiNTRY
Odoo POS Development Services by CandidRoot Solutions
Ad

Consumer driven contracts in java world

  • 2. About myself ● Application Architect @Thomas Cook ● Tech Lead - Platformers team ● +9 years Java
  • 3. Content ● Consumer Driven Contracts - general concepts; ● Consumer Driven Contracts - hygiene for APIs; ● Spring Cloud Contracts; ● Pact; ● Demo.
  • 8. They will be small and tidy
  • 10. And in a year we will see something like:
  • 13. Will your cool, modern microservices bring any value in terms of time-to-market...
  • 14. Will your cool, modern microservices bring any value in terms of time-to-market... ...without agreements/contracts between them?
  • 15. In terms of Quality Attributes: It’s never enough to comply with Runtime attributes when your Design attributes are not in order.
  • 16. We started with API Documentation at the time of decomposing our monolith
  • 17. But as time goes by we have come to realize it’s not enough...
  • 19. And our expectation was a system where services know about each other
  • 20. Standards are required for things like monitoring, logging, backward compatibility, and API contracts. API Contracts
  • 21. Lean principle: A service is of value to the business only to the extent it is consumed. https://martinfowler.com/articles/consumerDrivenContracts.html
  • 22. Make sure the Contracts can be imposed Set of rules and technologies that should be implemented and adopted on both sides.
  • 23. Do it as early as you can!
  • 24. Option 1: testing a chain of services without contracts
  • 25. You can go the hard way and deploy all microservices at once to test them together
  • 26. Drawbacks: ● Long cycle; ● Full Infrastructure required; ● Hard to debug; ● Very late feedback;
  • 27. Option 2: Mock other microservices in unit / integration tests
  • 28. Drawbacks: ● It simple has nothing to do with the reality if you do it in isolation.
  • 29. Postel's law “Be conservative in what you do, be liberal in what you accept from others (often reworded as "Be conservative in what you send, be liberal in what you accept").”
  • 30. Doesn’t Contract couple our services?
  • 32. Producer should have a contract for every specific Consumer
  • 33. It means that potentially there can be multiple contracts, a separate one for each Consumer,
  • 34. Contract visualisation: API: get: customers/{id} post: customers/ put: customers/{id} delete: customers/{id} get: customers/{id}/bookings/{id} post: customers/{id}/bookings/ delete: customers/{id}/bookings/{id}Producer
  • 35. API: get: customers/{id} post: customers/ put: customers/{id} delete: customers/{id} get: customers/{id}/bookings/{id} post: customers/{id}/bookings/ delete: customers/{id}/bookings/{id} Consumer 1 Producer get: customers/{id} post: customers/ put: customers/{id} Contract visualisation:
  • 36. API: get: customers/{id} post: customers/ put: customers/{id} delete: customers/{id} get: customers/{id}/bookings/{id} post: customers/{id}/bookings/ delete: customers/{id}/bookings/{id} Consumer 1 Producer Consumer 2 get: customers/{id} post: customers/ put: customers/{id} put: customers/{id} delete: customers/{id} Contract visualisation:
  • 37. API: get: customers/{id} post: customers/ put: customers/{id} delete: customers/{id} get: customers/{id}/bookings/{id} post: customers/{id}/bookings/ delete: customers/{id}/bookings/{id} Consumer 1 Producer Consumer 2 get: customers/{id} post: customers/ put: customers/{id} put: customers/{id} delete: customers/{id} Consumer 3 get: customers/ {id}/bookings/{id} post: customers/{id}/ bookings/ Contract visualisation:
  • 38. API: get: customers/{id} post: customers/ put: customers/{id} delete: customers/{id} get: customers/{id}/bookings/{id} post: customers/{id}/bookings/ delete: customers/{id}/bookings/{id} Consumer 1 Producer Consumer 2 get: customers/{id} post: customers/ put: customers/{id} put: customers/{id} delete: customers/{id} Consumer 3 get: customers/ {id}/bookings/{id} post: customers/{id}/ bookings/ Overlapping part of 2 contracts Contract visualisation:
  • 39. API: get: customers/{id} post: customers/ put: customers/{id} delete: customers/{id} get: customers/{id}/bookings/{id} post: customers/{id}/bookings/ Consumer 1 Producer Consumer 2 get: customers/{id} post: customers/ put: customers/{id} put: customers/{id} delete: customers/{id} Consumer 3 get: customers/ {id}/bookings/{id} post: customers/{id}/ bookings/ Overlapping part of 2 contracts Completely independent contract delete: customers/{id}/bookings/{id} Contract visualisation:
  • 40. API: get: customers/{id} post: customers/ put: customers/{id} delete: customers/{id} get: customers/{id}/bookings/{id} post: customers/{id}/bookings/ Consumer 1 Producer Consumer 2 get: customers/{id} post: customers/ put: customers/{id} put: customers/{id} delete: customers/{id} Consumer 3 get: customers/ {id}/bookings/{id} post: customers/{id}/ bookings/ Overlapping part of 2 contracts Completely independent contract delete: customers/{id}/bookings/{id} No in use Contract visualisation:
  • 41. Some parts of the APIs might not be used and will not impact anyone. They might either be in a state of active development or about to be decommissioned
  • 42. Demystification These tests are not component tests. They do not test the behaviour of the service deeply but that the inputs and outputs of service calls contain required attributes.
  • 43. Contract: specific scenario rather than schema Their main advantage is that they are fast and reliable.
  • 44. What tools are there for Java devs?
  • 45. There are 2 main options: 1. Spring Cloud Contracts; 2. Pact.
  • 46. Spring Cloud Contracts ● Spring Cloud Contract Verifier - the producer side; ● Spring Cloud Contract Stub Runner - the consumer side
  • 47. Spring Cloud Contracts: Contract Verifier Shipped with Contract Definition Language (DSL) written in Groovy or YAML.
  • 48. Spring Cloud Contract Verifier provides: ● Alignment between stubs and actual implementation; ● Acceptance test driven development; ● Immediate visibility of contracts on both sides; ● Autogenerated boilerplate tests.
  • 49. Spring Cloud Contracts: Contract Stub Runner ● Fetches the stubs of the producer; ● Runs tests against the stubs.
  • 50. Spring Cloud Contracts: Contract Definition Language
  • 51. There’s more if you read into specs: ● Groovy DSL ● YAML Spring Cloud Contracts: Contract Definition Language
  • 52. There’s more if you read into specs: ● Groovy DSL ● YAML ● Pact JSON ● Spring Rest Docs Spring Cloud Contracts: Contract Definition Language
  • 53. Spring Cloud Contracts - catchline “Spring Cloud Contract Verifier moves TDD to the level of software architecture.”
  • 54. SCC guarantees: ● Stubs reliability: generated on successful test execution. ● Stubs reusability: packed in a separate artifact with a stub classifier.
  • 55. Spring Cloud Contract: look inside
  • 56. Server / Producer side utilization: Maven/gradle plugin + verifier
  • 57. Server / Producer side: contract DSL Groovy YAML package contracts import org.springframework...t Contract.make { request { method 'PUT' url '/bookings/4' body(""" { "id": 4, "destination": "USA", …. } response { status 204 request: method: PUT url: /bookings/4 body: id: 4, destination: "USA" response: status: 204
  • 58. Server / Producer side: base class <baseClassForTests>....api.controllers.BookingControllerImplTest</...>
  • 59. Server / Producer side: base class The responsibility to initialising your MockMvc is on you: java.lang.IllegalStateException: You haven't configured a MockMVC instance. You can do this statically RestAssuredMockMvc.mockMvc(..) RestAssuredMockMvc.standaloneSetup(..); RestAssuredMockMvc.webAppContextSetup(..); or using the DSL: given(). mockMvc(..). ..
  • 60. Server / Producer side: producer stubs Spring Cloud Contract Verifier will convert the contracts into an HTTP server stub definitions(Wiremock mapping jsons).
  • 61. Demo time! ● Run Producer tests; ● Spring-cloud-contract-maven-plugin options; ● Run Consumer tests; ● Groovy DSL vs YAML; ● Add stateful behaviour(real MySql instance) for visibility; ● Non-binary storage(git); ● Explain stubrunner yaml property and how it impacts tests; ● Wiremock scenarios; ● produce(), consume() and matchers; ● execute() with custom utility methods; ● Integration with the rest of Spring Cloud.
  • 63. Pact: language support ● Ruby Pact ● JVM Pact and Scala-Pact ● .NET Pact ● JS Pact ● Go Pact (there is also a v1.1 native Pact Go) ● Swift / Objective-C Pact ● Python ● PHP
  • 64. Pact: objective The requirements of the consumer(s) are used to drive the features of the provider.
  • 65. Pact: diagram Consumer ● Specifies the contracts; ● Generates the pact files; ● Push them into Pact Broker
  • 66. Pact: diagram Consumer ● Specifies the contracts; ● Generates the pact files; ● Push them into Pact Broker Pact Broker ● Stores pact contracts; ● Integrates into CI tools.
  • 67. Pact: diagram Consumer ● Specifies the contracts; ● Generates the pact files; ● Push them into Pact Broker Pact Broker ● Stores pact contracts; ● Integrates into CI tools. Producer ● Implement a service according to Consumer specs.
  • 68. Demo time! ● Pact core concepts: State, Broker, Verification; ● Versioning; ● Pact extension for Spring Cloud Contracts;
  • 69. Useful links ● https://github.com/spring-cloud-samples/spring-cloud-contract-samples ● https://github.com/DiUS/pact-workshop-jvm ● https://github.com/DiUS/pact-jvm ● https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven
  • 70. Summary Use API Contracts ?: Adopt a design first approach ?: Document your APIs ?: You are hopeless
  • 71. Thank you! Mail: yura.v.nosenko@gmail.com Linkedin: https://www.linkedin.com/in/yuranos/ Github example: https://github.com/yuranos/raml-based-producer-application, https://github.com/yuranos/raml-based-consumer-application (consumer_driven_contracts branches)

Editor's Notes

  • #14: You can create very robust, scalable microservices with an expectation that it will get you closer to CD and bring true value to Business...
  • #15: CD Hotfixes. etc. You can create very robust, scalable microservices with an expectation that it will get you closer to CD and bring true value to Business... ...and completely screw it up by not adopting contracts between them, which will get you further from CD than you’ve ever been before.
  • #16: It has a lot to do with communitation. Runtime attributes(Scalability, Performance, Availability) Design attributes(Reusability, Maintanability, Integrity) If your ultimate goal is to build a distributed, microservice based system.
  • #21: and collaboration between services and people.
  • #22: As a result, providers expose a lean contract that is clearly aligned with the business goals that underpin their consumers.
  • #23: The Consumer-Driven Contract pattern is applicable in a single enterprise or a closed community.
  • #24: If you delay with API contracts, it will be a lot more challenging to get a buy-in from all development teams to adopt it when you are already running 10s/100s of services.
  • #25: Let’s say we don’t use any tools and decided to test our microservices together as an end to end flow
  • #28: Do you see a contraption like this very often in a real life?
  • #31: Contracts enable service independence; paradoxically, they can also couple service providers and consumers in undesirable ways. That’s why there are frameworks for that!
  • #34: and they can be quite different and only partially overlap or not overlap at all.
  • #44: As consumers of services, we need to define what exactly we want to achieve. We need to formulate our expectations. That is why we write contracts. Contract tests assert that the integration between the producer and the consumer meets the requirements defined in the contract.
  • #49: Spring Cloud Contract Verifier features: Ensure that HTTP / Messaging stubs (for client) are doing exactly what actual server-side implementation will do Promote acceptance test driven development method and Microservices architectural style Provide a way to publish changes in contracts that are immediately visible on both sides of the communication Autogenerated boilerplate test code used on the server side
  • #60: Very cool feature, because it allows you you use a webenvironment of your choosing.
  • #62: Wiremock output: logging by default Base classes: About Wiremock scenarios: TestRestTemplate is required. Otherwise 404 issue. About Wiremock scenarios: Content-type: very important to have. Otherwise, stubs will fail when called with RestTemplate. Disable FixedMethodOrder and show the results. https://github.com/spring-cloud-samples/spring-cloud-contract-nodejs https://spring.io/blog/2018/02/13/spring-cloud-contract-in-a-polyglot-world
  • #63: https://blog.risingstack.com/consumer-driven-contract-testing-with-pact/
  • #64: Something similar can be attempted by using Spring Cloud: In order to enable working with contracts while creating applications in non-JVM technologies, the springcloud/spring-cloud-contract Docker image has been created. It contains a project that automatically generates tests for HTTP contracts and executes them in EXPLICIT test mode. Then, if the tests pass, it generates Wiremock stubs and, optionally, publishes them to an artifact manager. In order to use the image, you can mount the contracts into the /contracts directory and set a few environment variables.
  • #65: Something similar can be attempted by using Spring Cloud: In order to enable working with contracts while creating applications in non-JVM technologies, the springcloud/spring-cloud-contract Docker image has been created. It contains a project that automatically generates tests for HTTP contracts and executes them in EXPLICIT test mode. Then, if the tests pass, it generates Wiremock stubs and, optionally, publishes them to an artifact manager. In order to use the image, you can mount the contracts into the /contracts directory and set a few environment variables.
  • #66: Something similar can be attempted by using Spring Cloud: In order to enable working with contracts while creating applications in non-JVM technologies, the springcloud/spring-cloud-contract Docker image has been created. It contains a project that automatically generates tests for HTTP contracts and executes them in EXPLICIT test mode. Then, if the tests pass, it generates Wiremock stubs and, optionally, publishes them to an artifact manager. In order to use the image, you can mount the contracts into the /contracts directory and set a few environment variables.
  • #67: Something similar can be attempted by using Spring Cloud: In order to enable working with contracts while creating applications in non-JVM technologies, the springcloud/spring-cloud-contract Docker image has been created. It contains a project that automatically generates tests for HTTP contracts and executes them in EXPLICIT test mode. Then, if the tests pass, it generates Wiremock stubs and, optionally, publishes them to an artifact manager. In order to use the image, you can mount the contracts into the /contracts directory and set a few environment variables.
  • #68: Something similar can be attempted by using Spring Cloud: In order to enable working with contracts while creating applications in non-JVM technologies, the springcloud/spring-cloud-contract Docker image has been created. It contains a project that automatically generates tests for HTTP contracts and executes them in EXPLICIT test mode. Then, if the tests pass, it generates Wiremock stubs and, optionally, publishes them to an artifact manager. In order to use the image, you can mount the contracts into the /contracts directory and set a few environment variables.
  • #69: Native Pact Broker only supports real HTTP transport. https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit
  • #72: https://unsplash.com/collections/239831/typography - slogans https://unsplash.com/collections/203782/in-transit - travelling, transportations, on the road https://unsplash.com/collections/261936/technology - mostly phones and laptops https://unsplash.com/collections/881815/au-naturel - desktop wallpapers https://unsplash.com/collections/345744/urban-architecture https://unsplash.com/collections/589374/textures - abstract patterns https://unsplash.com/collections/227/shapes-patterns-textures - abstract patterns https://unsplash.com/collections/416021/abstract - abstract patterns https://unsplash.com/collections/1240111/its-simple-but-very-complex - patterns(nature, architecture) https://unsplash.com/collections/420324/blurrrr - nice pics of different blurred sceneries https://unsplash.com/collections/770996/creative-spaces - office environment https://unsplash.com/collections/385548/work-and-collaboration https://unsplash.com/collections/361687/architectural-lines - architecture, buildings https://unsplash.com/collections/1439704/facade - building facades https://unsplash.com/collections/1136512/%E2%98%85-textures-colors - slogans and sceneries https://unsplash.com/collections/345761/sport - sports