Spring Data R2DBC - Transactions
Introduction
In Spring, R2DBC is one of the integrations for reactive transactions. Reactive transactions are managed through Reactor contexts, in contrast to traditional transactions, in which transactional state is associated with a thread. In addition to covering reactive transactions within Spring framework, this article gives a solid knowledge about how Spring Boot magic works under the hood.
I highly recommend taking a look at Reactor context before diving into this article.
A quick tour of JDK Proxy
This section discuss Java’s dynamic proxies, a very powerful feature allowing one single class with one single method to service multiple method calls to arbitrary classes with an arbitrary number of methods.
JDK Dynamic proxy can only back interfaces, that is, your target class needs to implement an interface, which will in turn be implemented by the proxy. All method invocations gets routed to an InvocationHandler. The handler inspects the method and delegates it according to defined logic.
The Proxy class
Proxy provides static methods for creating objects that act like instances
of interfaces but allow for customized method invocation.