Going Reactive - High Performance JVM code with Reactor
I gave this talk at JAX 2014. It is an introduction into reactive programming, why its needed and how the Reactor framework can help you achieve those goals.
8
What
is
Reactor?
• Founda6onal
library
• Lives
between
user
and
low-‐level
code.
• Suite
for:
drivers,
libraries,
event-‐driven
systems
• Part
of
Spring
IO
• 1.1.0
Released
(h?ps://github.com/reactor/reactor)
11
Dispatchers
• Per
Environment
• Manage
Task
Execu6on.
ThreadPoolExecutorDispatcher
execu>ng
tasks
in
a
thread
pool
EventLoopDispatcher
mul>ple
event
loops
dispatching
tasks
RingBufferDispatcher
uses
the
LMAX
Disruptor
RingBuffer
ActorDispatcher
to
pin
keys
to
threads
SynchronousDispatcher
for
tes>ng
12
Selectors
• Lea-‐hand
side
of
an
equality
comparison.
• Can
be
created
from
any
object.
$(object)
Selectors.object(obj)
• Can
extract
data
from
the
matched
key.
20
Integra6on:
Spring
• Helpers
to
integrate
Reactor
into
ApplicationContext
@EnableReactor
Wiring
annotated
handlers
• DispatcherTaskExecutor
Not
intended
for
“high
scale”
Used
to
get
Spring
components
running
in
the
same
thread
as
Reactor
consumers.