際際滷

際際滷Share a Scribd company logo
Reactive Microservices In Action
Emily Jiang
Java Champion
STSM, IBM
Liberty Microservice Architect, Advocate
MicroProfile Architect @IBM
@emilyfhjiang
2
Why Reactive?
3
Synchronous calls
Two microservices...
BA
Two microservices...
BA
data/client/test/hello data/service/hello
h艶鉛鉛看 h艶鉛鉛看
data/client/test/hello data/service/hello
h艶鉛鉛看 h艶鉛鉛看
 Interacting using synchronous calls
7
Asynchronous calls
Asynchronous calls (because its trendy)
Microservices are like kids...
Need mudguards
(a)
(b)
(c)
(a)
(b)
(c)
MicroProfile Fault-Tolerance
Sorry, Im out of context...
Ive lost my thread locals!
(User, Transaction, Correlation
Id)
MicroProfile Context Propagation
Restore the
context
Capture the
context
MicroProfile Context Propagation
Most asynchronous things
ARENT non-blocking.
You need
asynchrony + non-blocking
to use resources
efficiently
 Is this what you want?
Non-Blocking IOAsynchronous,
Fault-Tolerance
Context
Propagation
 And they lived together happily ever after.
???
!!!
18
Reactive
19
What Reactive?
System eXtensions
Programming
Manifesto
Streams
Asynchrony
Back-Pressure
Resilience
Elasticity
Spreadsheets
Actor
Data Flows
Observable
Events
Messages ReactorRX JavaResponsiveness
Fibers
Non-Blocking
MicroProfile
Spring
RSocket
Reactive all the things ???
Mutiny
21
System eXtensions
Programming
Manifesto
Streams
Asynchrony
Back-Pressure
Resilience
Elasticity
Spreadsheets
Actor
Data Flows
Observable
Events
Messages ReactorRX JavaResponsiveness
Fibers
Non-Blocking
MicroProfile
Spring
RSocket
Reactive all the things ???
Mutiny
Quarkus
22
Reactive Programming
Data
Streams
Propagation
of changes
23
Reactive Extensions
Data
Streams
Propagation
of changes
24
Reactive Streams
Data
Streams
Propagation
of changes
Back
Pressure
Protocol
25
Reactive Streams - Java 9+ edition
Observable Stream of <T>
Stream Observer
On new item
On failure
On completion
26
Reactive Streams - Java 9+ edition
The contract between the
observer and the stream
Stop the observation
Request items
27
Reactive Streams - How does that work?
Subscriber Publisher
(1)subscribe
(2) onSubscribe(sub)
28
Reactive Streams - How does that work?
Subscriber Publisher
(3) request(x)
(4) onNext(i1)
(5) onNext(i2)
(6) onComplete()
29
Reactive Streams - How does that work?
Subscriber Processor Publisher
subscribe
request(x)
subscribe
request(x)
30
http://www.reactivemanifesto.org/
Reactive Systems
31
How Reactive?
Applying reactive to microservices
Temporal
decoupling
Back-Pressure
Protocol
Using messages to achieve decoupling
BA
Sent to virtual addresses
Can be durable (temporal
decoupling)
Use non-blocking IO
Messaging / Streaming
MicroProfile
Application Code
Container Host / Operating System
Async HTTP Messaging
MicroProfile
Application Code
Container Host / Operating System
MicroProfile Reactive Messaging
MicroProfile
Reactive Messaging
35
MicroProfile Reactive Messaging
36
MicroProfile Reactive Messaging
Connector
configuration
(protocol specific)
37
MicroProfile Reactive Messaging
Reactive
Streams
Reactive architecture
BA
Decoupling, Elasticity, Resilience,
Back-Pressure, Asynchrony, Non-Blocking
https://github.com/Emily-Jiang/reactive-service-a
https://github.com/Emily-Jiang/reactive-service-b
39
Demo
References
 Defining the term reactive
https://developer.ibm.com/articles/defining-the-term-reactive/
 Develop reactive microservices with Reactive Messaging
https://developer.ibm.com/articles/develop-reactive-microservices-with-
microprofile/
 Open Liberty guides on Reactive
https://openliberty.io/guides/?search=reactive
 MicroProfile Reactive Messaging
https://github.com/eclipse/microprofile-reactive-messaging
 MicroProfile Fault Tolerance
https://github.com/eclipse/microprofile-fault-tolerance/
 MicroProfile Context Propagation
https://github.com/eclipse/microprofile-context-propagation
Thank you
41
Emily Jiang
STSM, Liberty Microservice Architect and Advocate
IBM
@emilyfhjiang
Dr. Clement Escoffier
Senior Principal Software Engineer
Red Hat
@clementplop

More Related Content

Reactive microserviceinaction