consumer driven contracts and your microservice architecture @ warsaw jug
TRANSCRIPT
![Page 1: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/1.jpg)
1 © 2016 Pivotal
Consumer Driven Contracts and Your Microservice Architecture
Marcin Grzejszczak, @mgrzejszczak
![Page 2: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/2.jpg)
2
background image: 960x540 pixels - send to back of slide and set to 80% transparency
Spring Cloud developer at PivotalWorking mostly on
● Spring Cloud Sleuth ● Spring Cloud Contract● Spring Cloud Pipelines
About me
Twitter: @mgrzejszczakBlog: http://toomuchcoding.com
![Page 3: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/3.jpg)
3
background image: 960x540 pixels - send to back of slide and set to 80% transparency
Introduction
Demo
Summary
Agenda
![Page 4: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/4.jpg)
4
What we will NOT be talking about?
![Page 5: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/5.jpg)
5
●
●
●
●
●
What we will NOT be talking about?
THE IDEA OF SPRING CLOUD CONTRACT IS NOT TO
INTRODUCE UNNECESSARY COUPLING OR REPLICATE OLD
MISTAKES
![Page 6: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/6.jpg)
6
●
○
●
○
●
○
●
○
Introduction
![Page 7: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/7.jpg)
7
●
●
Introduction
What problems are we trying to solve?
![Page 8: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/8.jpg)
8
Introduction
Typical situation
HTTP
CONSUMER PRODUCER
![Page 9: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/9.jpg)
9
Introduction
How to write a test for it?
HTTP
CONSUMER PRODUCER
![Page 10: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/10.jpg)
10
Introduction
How to write a test for it?
HTTP
CONSUMER PRODUCER
![Page 11: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/11.jpg)
11
Introduction
Stub validity & reusability
WE’RE ON THE CONSUMER SIDE!!
CONSUMER OWNS THE STUB DEFINITIONS
![Page 12: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/12.jpg)
12
Introduction
Stub validity & reusability
![Page 13: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/13.jpg)
13
Introduction
Let’s assume that we’re introducing a new endpoint...
![Page 14: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/14.jpg)
14
Introduction
Stub validity & reusability
![Page 15: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/15.jpg)
15
●
●
●
Introduction
So now what?
![Page 16: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/16.jpg)
16
Introduction
Ooops...
![Page 17: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/17.jpg)
17
Introduction
What went wrong?
HTTP
CONSUMER PRODUCER
TEST
OK
HTTP
CONSUMER PRODUCER
REALITY
WAT?!
![Page 18: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/18.jpg)
18
Introduction
Another example with messaging
CONSUMERPRODUCER
TEST
PRODUCER CONSUMER
REALITY
topic: bar topic: foo
topic: bar
![Page 19: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/19.jpg)
19
●
●
●
●
●
●
Introduction
Stub validity & reusability
![Page 20: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/20.jpg)
20
●
●
●
Introduction
Nice API creation
![Page 21: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/21.jpg)
21
Introduction
Nice API creation - no cooperation results
![Page 22: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/22.jpg)
22
Introduction
Nice API creation - no cooperation results
![Page 23: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/23.jpg)
23
Demo
Potential answer
Spring Cloud Contract
![Page 24: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/24.jpg)
24
●
○
○
●
○
●
○
○
Demo
What are we going to code?
![Page 25: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/25.jpg)
25
●
○
●
○
●
○
Demo
What are we going to code?
![Page 26: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/26.jpg)
26
Introduction
What are we going to code?
I’m 22 give me a beer
CONSUMER PRODUCER
There you go!
Can he get the beer?
Yes!
![Page 27: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/27.jpg)
27
Introduction
What are we going to code?
I’m 17 give me a beer
CONSUMER PRODUCER
Get lost!
Can he get the beer?
No!
![Page 28: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/28.jpg)
28
Introduction
What are we going to code?
Someone’s 22. Check him out!
CONSUMERPRODUCER
Positive verification took place
Messaging
![Page 29: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/29.jpg)
29
Introduction
What are we going to code?
Someone’s 17. Check him out!
CONSUMERPRODUCER
Negative verification took place
Messaging
![Page 30: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/30.jpg)
30
Introduction
What are we going to code?
BLACK TERMINALBLACK IDE
CONSUMER
WHITE TERMINALWHITE IDE
PRODUCER
![Page 31: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/31.jpg)
31
Demo
![Page 32: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/32.jpg)
32
Summary
![Page 33: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/33.jpg)
33
Summary
PRODUCER CONSUMER
![Page 34: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/34.jpg)
34
Summary
PRODUCER
CONSUMER CLONES
PRODUCER
PRODUCERCLONE CONSUMER
![Page 35: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/35.jpg)
35
Summary
PRODUCER CONSUMERCONSUMER
CLONES PRODUCER
PRODUCERCLONE
INTERACTION
![Page 36: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/36.jpg)
36
Summary
PRODUCER CONSUMERPRODUCER
CLONE
INTERACTION
CONSUMER FILES A PR
![Page 37: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/37.jpg)
37
Summary
![Page 38: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/38.jpg)
38
Summary
PRODUCER
TAKES OVER THE PR
![Page 39: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/39.jpg)
39
Summary
PRODUCER
TAKES OVER THE PR
WRITES THE MISSING IMPLEMENTATION
![Page 40: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/40.jpg)
40
Summary
PRODUCER
TAKES OVER THE PR
WRITES THE MISSING IMPLEMENTATION
MERGES TO MASTERCI UPLOADS TO NEXUS /
ARTIFACTORY
![Page 41: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/41.jpg)
41
Summary
![Page 42: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/42.jpg)
42
Summary
CONSUMER
SWITCHES TO ONLINE MODE
DOWNLOADS STUBS OF COLLABORATORS DURING
BUILD PHASE
![Page 43: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/43.jpg)
43
Summary
![Page 44: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/44.jpg)
44
Summary
![Page 45: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/45.jpg)
45
I don’t want to keep my contracts with the producer
![Page 46: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/46.jpg)
46
Demo
![Page 47: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/47.jpg)
47
Common repo with contracts - consumer
PRODUCER CONSUMER
![Page 48: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/48.jpg)
48
Common repo with contracts - consumer
PRODUCER CONSUMER
REPO WITH CONTRACTS
![Page 49: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/49.jpg)
49
Common repo with contracts - consumer
PRODUCER CONSUMER
REPO WITH CONTRACTS
GIT CLONE
CLONED REPO WITH
CONTRACTS
![Page 50: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/50.jpg)
50
Common repo with contracts - consumer
PRODUCER CONSUMER
REPO WITH CONTRACTS
GIT CLONE
CLONED REPO WITH
CONTRACTS
INTERACTION
![Page 51: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/51.jpg)
51
Common repo with contracts - consumer
PRODUCER CONSUMER
REPO WITH CONTRACTS
CLONED REPO WITH
CONTRACTS
PR
![Page 52: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/52.jpg)
52
Common repo with contracts - producer
PRODUCER CONSUMER
REPO WITH CONTRACTS
![Page 53: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/53.jpg)
53
Common repo with contracts - producer
PRODUCER CONSUMER
REPO WITH CONTRACTS
CLONED REPO WITH
CONTRACTS
PRODUCER
TAKES
OVER PR
![Page 54: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/54.jpg)
54
WRITES THE MISSING IMPLEMENTATION
Common repo with contracts - producer
PRODUCER CONSUMER
REPO WITH CONTRACTS
CLONED REPO WITH
CONTRACTS
PRODUCER
TAKES
OVER PR
![Page 55: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/55.jpg)
55
WRITES THE MISSING IMPLEMENTATION
Common repo with contracts - producer
PRODUCER CONSUMER
REPO WITH CONTRACTS
CLONED REPO WITH
CONTRACTS
MERGE PR
![Page 56: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/56.jpg)
56
WRITES THE MISSING IMPLEMENTATION
Common repo with contracts - producer
PRODUCER CONSUMER
REPO WITH CONTRACTS
CI UPLOADS TO NEXUS
/ ARTIFACTORY
![Page 57: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/57.jpg)
57
●●
●●●
I don’t want to keep my contracts with the producer
![Page 58: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/58.jpg)
58
I don’t want to write any scripts!
![Page 59: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/59.jpg)
59
Introduction
Don’t worry! You can use Spring Cloud Contract WireMock with Rest Docs!!
![Page 60: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/60.jpg)
60
Demo
![Page 61: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/61.jpg)
61
●
●
●
●
●
Summary
![Page 62: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/62.jpg)
62
●
●
●
●
●
●
Summary
![Page 63: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/63.jpg)
63
QUESTIONS
![Page 64: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/64.jpg)
64
Learn More. Stay Connected.
▪ Read the docs
▪ Check the samples
▪ Talk to us on Gitter
Twitter: twitter.com/springcentral
YouTube: spring.io/video
LinkedIn: spring.io/linkedin
Google Plus: spring.io/gplus
![Page 65: Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG](https://reader034.vdocument.in/reader034/viewer/2022042708/587bbb071a28abb8258b63e5/html5/thumbnails/65.jpg)
65
mgrzejszczak