Nick Fisher's tech blog

Java

Continuous Subscriptions in Reactor

There are use cases for wanting to immediately subscribe to a Flux or a Mono immediately after the subscription has completed. The most obvious use case is if your application needs to continuously poll for values.

A Guide to Automatic Retries in Reactor

The source code for this post is available on GitHub.

One of the nice things about a reactive programming model is there is a significantly lower risk of doomsday when things start getting latent all at once. You don’t have threads upstream blocking and waiting for a response, therefore they won’t all seize up and stop serving requests [or they won’t short circuit if you’re using a resiliency library like hystrix].

How to Mock Dependencies and Unit Test in Spring Boot Webflux

The source code for this post can be found on Github.

The most straightforward way to write unit tests in spring boot webflux is to leverage project reactor’s StepVerifier. StepVerifier allows you to pull each item in a Flux or the only potential item in a Mono and make assertions about each item as it’s pulled through the chain, or make assertions about certain errors that should be thrown in the process. I’m going to quickly walk you through an example integrating mockito with it and webflux.

OpenAPI and Spring Boot Webflux: A Working Introduction

The OpenAPI Specification is an “industry standard” way of declaring the API interface. As REST APIs using JSON have dominated the way we move data around in most organizations and on the internet, particularly in service oriented architectures, and as documentation at almost every company has been written once, read a couple of times, then lost to the wind, smart people have figured out that they can put the documentation for their services living with the code–better yet, displayed while the app is running.

How to Forward Request Headers to Downstream Services in Spring Boot Webflux

The source code for this post can be found on Github.

When you make the switch to a reactive codebase, ThreadLocal becomes effectively off limits to you, because you aren’t guaranteed that the thread that starts the request processing remains the same, even if it’s the same HTTP request. This has caused pain in many places: the original implementation of spring security, for example, relied very heavily on ThreadLocal variables to store state that happened in the start of the request, and then reuse the information stored in those variables later on to make access control decisions. Neflix spoke of their pain migrating to a reactive stack, when they had relied so heavily on ThreadLocal variables in most of their shared libraries.

How to Configure Rest Assured to Record the Latency of Every Request In a Custom Way

Sample code associated with this post can be found on Github.

Rest Assured is a library that makes it easy to write api based automated tests in java. Recently I needed to find a way to record the latency of each request as well as some metadata about it [request path, method, things of that nature]. I found a nice way to do this with rest assured filters, and I’m going to share that with you in this article.

The Hystrix Parameters You Actually Need to Tune in Spring Boot

There is some [hacky] code for this post on Github.

The number of hystrix configuration options, as of this writing, is about 34. In reality, you don’t need to worry about most of them, as the defaults are perfectly reasonable. This article discusses those parameters that, in my experience, you typically need to pay attention to and tune, and I have provided some examples using spring boot’s support for hystrix via the javanica library.

Newer Posts