Posts by Michel Breevoort

OpenAPI: Different API versions with Springdoc

Posted on by  
Michel Breevoort

With Springdoc you can create a Swagger UI and generate the OpenAPI spec file. In a project it is a good practice to support version n - 1 of the API for backwards compatibility. The problem is that some objects have the same name and then the last parsed object is used for all versions in the OpenAPI spec. In this post the solution with definitions is shown.

Continue reading →

Elasticsearch: blazing fast products per category

Posted on by  
Michel Breevoort

This post will show how to create a list with how many products there are in a category and their sub categories with Elasticsearch aggregations covered with tests.

On our site there are products with a category and they have a sub category, for example product category is shoes and sneakers is a sub category.

shirts (134)
shoes (254)
    - running (54)
    - sneakers (200)

Continue reading →

Spring WebFlux : reactor meltdown - slow responses

Posted on by  
Michel Breevoort

WebFlux is the reactive web framework for Spring. The programming model is easy but using it could be cumbersome if you don’t know the consequences when used incorrectly. This post will show what the consequences are when the reactive-stack is not used correctly. It will answer the question: why is my (health) endpoint sometimes so slow?

TL DR; Don’t block the event loop

Continue reading →

Spicy Spring : Scheduler does not shutdown

Posted on by  
Michel Breevoort

On my current project we use Java 8, Spring 4.3 and Tomcat 7.0 as application server. After the scheduling functionality was added to the project the application server did not shut down any more, it hung till the end of time. I like to use the default Java implementations when possible so the configured scheduler was the java.util.concurrent.ScheduledThreadPoolExecutor.

After some investigation we found out that the application server did not shutdown because the created ScheduledExecutorService bean did not stop. The threads in the thread pool didn’t stop when the application context is destroyed. The destroyMethod is defined and Spring calls the shutdown method but it still did not stop the application server. When I tested with Spring Boot it shuts down without a problem. Spring has also their own ThreadPoolTaskScheduler with much more configuration options. Strangely it does not implement the same interface java.util.concurrent.ScheduledExecutorService as I would expect from the Spring framework but you can use both implementations.

Continue reading →

shadow-left