Professional Documents
Culture Documents
Emily Jiang
Java Champion
STSM, IBM
2
Synchronous calls
3
Two microservices...
A B
Two microservices...
data/client/test/hello data/service/hello
A B
“hello” “hello”
… Interacting using synchronous calls
data/client/test/hello data/service/hello
“hello” “hello”
Asynchronous calls
7
Asynchronous calls (because it’s trendy)
Microservices are like kids...
(b)
(a)
(c)
Need mudguards
MicroProfile Fault-Tolerance
(b)
(a)
(c)
Sorry, I’m out of context...
Capture the
context
Restore the
context
MicroProfile Context Propagation
Most asynchronous things
AREN’T non-blocking.
You need
asynchrony + non-blocking
to use resources
efficiently
… Is this what you want?
Context
Propagation
Asynchronous, Non-Blocking IO
Fault-Tolerance
… And they lived together happily ever after.
???
!!!
Reactive
18
What Reactive?
19
Reactive all the things ??? Observable Spring
System eXtensions
Manifesto Elasticity
Fibers
Streams Back-Pressure
Programming
Events Data Flows RSocket
Spreadsheets
Reactive all the things ??? Observable Spring Quarkus
System eXtensions
Manifesto Elasticity
Fibers
Streams Back-Pressure
Programming
Events Data Flows RSocket
Spreadsheets
21
Reactive Programming
Data Propagation of
Streams changes
22
Reactive Extensions
t Streams
Implemen
Type and
Reactive
Prog. Operators
Data Propagation
Streams of changes
23
Reactive Streams
RX Java,
t Streams
Implemen Reactor,
Type and
Reactive Mutiny,
Prog. Operators
Reactive
Streams Ops
Back
Data Propagation
Pressure
Streams of changes
Protocol
24
Reactive Streams - Java 9+ edition
Stream Observer
On new item
On failure
On completion
25
Reactive Streams - Java 9+ edition
(1)subscribe
Subscriber Publisher
(2) onSubscribe(sub)
27
Reactive Streams - How does that work?
(3) request(x)
Subscriber Publisher
(4) onNext(i1)
(5) onNext(i2)
(6) onComplete()
28
Reactive Streams - How does that work?
subscribe subscribe
request(x) request(x)
29
Reactive Systems
http://www.reactivemanifesto.org/
Message
Asynchronous
Passing
30
How Reactive?
31
Applying reactive to microservices
Temporal
decoupling
Back-Pressure
Protocol
Using messages to achieve decoupling
A B
MicroProfile Reactive Messaging
MicroProfile MicroProfile
Messaging / Streaming
Async HTTP Messaging
MicroProfile
Reactive Messaging
MicroProfile Reactive Messaging
35
MicroProfile Reactive Messaging
Connector
configuration
(protocol specific)
36
MicroProfile Reactive Messaging
Reactive
Streams
37
Reactive architecture
A B
Demo
https://github.com/Emily-Jiang/reactive-service-a
https://github.com/Emily-Jiang/reactive-service-b
39
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
Emily Jiang
STSM, Liberty Microservice Architect and Advocate
IBM
@emilyfhjiang
41