際際滷

際際滷Share a Scribd company logo
Reactive Microservices in
Action
Emily Jiang
Java Champion
STSM, IBM
Liberty Microservice Architect, Advocate
Senior Lead for MicroProfile and CDI
@emilyfhjiang
Clement Escoffier
Java Champion
Chief Architect, Red Hat
@clementplop
2
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
6
Asynchronous calls
Asynchronous calls (because its trendy)
CompletionStage<String> cs =
service.doSomething().thenApply(result -> {
//next instruction
});
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
Lets go back to this asynchronous calls...
Most asynchronous things
ARENT non-blocking.
Dust under the carpet
h艶鉛鉛看 h艶鉛鉛看
Hidden
thread pool
data/client/test/hello data/service/hello
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.
???
!!!
19
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 ???
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 ???
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
How does it fix my
two microservices
Applying reactive to microservices
Temporal
decoupling
Back-Pressure
Protocol
32
http://www.reactivemanifesto.org/
Reactive Systems
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
Thank you
40
Emily Jiang, IBM
@emilyfhjiang
Clement Escoffier, Red Hat
@clementplop

More Related Content

Reactive microserviceinaction@devnexus