![Page 1: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/1.jpg)
Microservices communication and integration: what are my options?
Kate Stanley
@KateStanley91
Jfokus – February 2016
![Page 2: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/2.jpg)
Introduction
Software engineer
WebSphere Liberty
Microservices
@KateStanley91
![Page 3: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/3.jpg)
Contents
What are microservices?
Why is communication important?
Microservice communication options
Producing and consuming APIs
Conclusion
![Page 4: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/4.jpg)
What are microservices?
![Page 5: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/5.jpg)
…compose a complex application using:“small”
independent (autonomous)
replaceable
processes
…that communicate via:language-agnostic APIs
Microservices are used to…
Microservice
MicroserviceMicroservice
Microservice
Microservices application
Subscribe
REST
(JSON/HTTP)
Microservice
Microservice
broker
API
MicroservicePublish
API
REST
(JSON/HTTP)
Publish
Service
Registry
API
Microservice
![Page 6: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/6.jpg)
Why is communication important?
![Page 7: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/7.jpg)
How my team communicates
Different locations
Different timezones
Different languages…?!
“The United States and Great Britain are two countries separated by a common language.”
![Page 8: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/8.jpg)
How my team communicates
Data type:Text, speech, body language
Infrastructure:Email, Slack, Skype
Characteristics:Delayed (Email) / Immediate (Skype)
Hello!
Howdy!
![Page 9: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/9.jpg)
Data type:JSON / XML / binary
Infrastructure:Service registry
Service proxy
Characteristics:Asynchronous
Synchronous
Microservices communication
Microservice Microservice
Microservice
?
![Page 10: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/10.jpg)
Communication infrastructure options
![Page 11: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/11.jpg)
Service Registry
Store of available microservices
Provides:Registration, Healthcheck, Service Discovery, De-registration
Consistency vs Availability
Examples:Eureka, Consul, Amalgam8
![Page 12: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/12.jpg)
Routing via service proxy
AdvantagesSimple requests
Simple tests Microservice
Microservice
Service
Registry
Service
Proxy
Registry requests
Proxy requests
![Page 13: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/13.jpg)
Routing via service proxy
DisadvantageMore network hops
Microservice
Microservice
Service
Registry
Service
Proxy
1
23
4
Registry requests
API requests
![Page 14: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/14.jpg)
Client-side routing
Less network hops
Microservice MicroserviceService
Registry
1
2
Registry requests
API requests
![Page 15: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/15.jpg)
Client-side routing
Client libraryLanguage specific
Easy debugging
SidecarLanguage agnostic
Harder to debug failures
Microservice
Microservice
Microservice
Service
Registry
Client library
app
sidecar Registry requestsAPI requests
![Page 16: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/16.jpg)
API Gateway
Provides coarse grained APIs
Useful for:API metering
JWT injection
Microservice
Microservice
Microservices application
REST
(JSON/HTTP)
Microservice
API
MicroservicePublish
API
REST
(JSON/HTTP)
Service
Registry
API
API Gateway
![Page 17: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/17.jpg)
Communication characteristics
![Page 18: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/18.jpg)
Synchronous vs asynchronous protocol
Synchronous e.g. REST, HTTPRequires a response
Utilise asynchronous programming model
Asynchronous e.g. messagingNo response required
![Page 19: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/19.jpg)
Example – Game On
![Page 20: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/20.jpg)
Example – Game On!
Interactive mapOutside of core microservices
Displays room location and name
![Page 21: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/21.jpg)
Example – Game On
![Page 22: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/22.jpg)
ExternalDatastore Interactive Map
Map Service
Network boundary
Logical boundary
Rest/HTTP
API
Authenticated User
Broker
Publish
Subscribe
(1)
(2)
(3)
(4)
![Page 23: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/23.jpg)
Messaging in Game On!
Apache Kafka locally
MessageHub in the cloud
![Page 24: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/24.jpg)
Microservice design
Design influenced by communication
Consider latencyMicroservice
MicroserviceMicroservice
Microservice
Microservices application
Subscribe
REST
(JSON/HTTP)
Microservice
Microservice
broker
API
MicroservicePublish
API
REST
(JSON/HTTP)
Publish
Service
Registry
API
Microservice
![Page 25: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/25.jpg)
ELK mongo
room
Player
Proxy
JSON/HTTP (REST)
Concierge
• Player managed ”all interactions with the player”
• Concierge: tell player service which room is next
(/go N)
• Room (had to have one!)
First pass
![Page 26: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/26.jpg)
kafkaELK couchdb
room
Player
Proxy
Mediator
Now..
Concierge
![Page 27: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/27.jpg)
Producing and consuming APIs
![Page 28: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/28.jpg)
APIs change!
Breaking changesAlter methods and data
Non-breaking changes (theoretically!)Add data or methods
![Page 29: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/29.jpg)
Being a good consumer
Accept the unknown
Only validate against the required
Fault tolerance important – another talk!
![Page 30: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/30.jpg)
Being a good producer
Golden rule: don’t break your consumers
If you need to break something - use versioning
Accept unknown attributes
Only return attributes relevant to the request
![Page 31: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/31.jpg)
Robustness principle
“Be conservative in what you send,
be liberal in what you accept”
https://en.wikipedia.org/wiki/Robustness_principle
![Page 32: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/32.jpg)
Documenting APIs
Consumer driven contract tests
Swagger
![Page 33: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/33.jpg)
Conclusion
![Page 34: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/34.jpg)
Conclusion
Choose service discovery and invocation method
Use both asynchronous and synchronous protocols
Design influenced by communication
Robustness principle
![Page 35: Microservices communication and integration: what are my … · 2019-09-11 · Microservices communication and integration: what are my options? Kate Stanley @KateStanley91 Jfokus](https://reader030.vdocuments.us/reader030/viewer/2022041014/5ec5b94726ea6d3c9424f68c/html5/thumbnails/35.jpg)
Thank you!
Play the game – http://gameontext.org
Build rooms – http://github.com/gameontext
Learn more:
http://wasdev.net
Microservices Best Practices for Java http://www.redbooks.ibm.com
Kate Stanley | [email protected] | @KateStanley91