Going Reactive - High Performance JVM Code with Reactor
This talk was given at DevFest Vienna 2013, featuring an introduction into the Reactor framework (https://github.com/reactor/reactor) combined with exhaustive demos.
8
What
is
Reactor?
• A
founda+onal
library
to
build
reac+ve
applica+ons.
• Gray
area
between
user-‐
and
low-‐level
code.
• Build
your
applica+on
cores
on
top
of
it.
• Helps:
drivers,
servers,
libraries,
evented
architectures.
• Maintained
by,
but
no
dependency
on
Spring.
• Currently
in
RC
state!
(hGps://github.com/reactor/reactor)
11
Dispatchers
• Created
on
an
Environment-‐basis.
• Dispatchers
manage
Task
Execu+on.
ThreadPoolExecutorDispatcher
execuCng
tasks
in
a
thread
pool
BlockingQueueDispatcher
event-‐loop
style
RingBufferDispatcher
uses
the
LMAX
Disruptor
RingBuffer
SynchronousDispatcher
for
tesCng
12
Selectors
• LeY-‐hand
side
of
an
equality
comparison.
• Can
be
created
from
any
object.
$(object)
Selectors.object(obj)
• Can
extract
data
from
the
matched
key.
19
Integra+on:
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.
TCP
Client/Server
based
on
Ne>y
4
Buffer
tooling
Sequencing
for
event
ordering
Work
Queue
support
on
top
of
Java
Chronicle
Logback
Appender
Language
Constructs
(Composables,
Tuples,…)