Reactive is being supported in more and more widely adopted frameworks and languages. We are expecting to see more coding along reactive paradigms, especially in systems of high throughput.
But what does it mean to go reactive with a team of people coming from a mostly imperative world? In what ways does it feel different, how do you get in the flow and how do you onboard new team members?
2. Key facts:
OTTO in numbers
● 3.2 Billion € revenue
● 90% of revenue generated online,
● Up to 10 orders per second
Platform
● Leveraging OTTO brand
● Brokering customer:partner relationships
● Platform services.
3. The Mission
Pricing
The only source of truth for any price calculations on the
marketplace.
Expected requirements:
● high load
● low latency
7. 2. Use Spring WebFlux as web framework
Status
Context
Decision
Consequences
Date 2018 - 07 - 03
Accepted
Bootstrapping the pricing
We chose Spring WebFlux (reactive stack), rather than Spring MVC due to an overall
curiosity in it.
Monitor whether WebFLux works well for our context - should it get in the way, we
may have to consider migrating to Spring MVC
21. Expressiveness
Through the valley of tears
https://github.com/MostlyAdequate/mostly-adequate-guide
Readability
Imperative Declarative
Where many
developers give up
on learning FP
Where we
feel we are
22. public Mono<ServerResponse> handle(ServerRequest request) {
return request
.bodyToMono(ProductMapper.class)
.map(ProductMapper::toProduct)
.flatMap(product -> sendMessage(product).then(ServerResponse.accepted().build()))
.doOnError(e -> log.error("Failed to publish product", e))
.onErrorResume(
CodecException.class,
e -> ServerResponse.status(HttpStatus.UNPROCESSABLE_ENTITY).build())
.onErrorResume(e -> ServerResponse.status(HttpStatus.SERVICE_UNAVAILABLE).build())
.switchIfEmpty(ServerResponse.badRequest().build());
}
24. Problems that used to be solved
● Swagger
Does not work with Router Function approach
● Togglz
Web console only available for WebMVC
It’s the environment, stupid
25. Beware!
● block() throws assert
● subscribe on main thread pool
● Debugging
More or less subtle pitfalls