javacodegeeks.com

Callback hell and Reactive patterns

One of the ways that I have better understood the usefulness of aReactive Streams based approach is how it simplifies a Non-blocking IO call.This post will be a quick walkthrough of the kind of code involved in making a synchronous remote call, then show how layering in Non-blocking IO though highly efficient in the use of resources(especially threads) introduces complications referred to as a callback hell and how

javacodegeeks.com

Functional Hystrix using Spring Cloud HystrixCommands

Spring’s WebClient provides a non-blocking client for making service to service calls.Hystrix, though now in a maintenance mode, has been used for protecting service to service calls by preventing cascading failures, providing circuit breakers for calls to slow or faulty upstream services.In this post, I will be exploring how Spring Cloud provides a newer functional approach to wrapping a remote call with Hystrix.Consider a simple

javacodegeeks.com

Spring-Boot 2.1.x and overriding bean definition

I was recently migrating an application from Spring Boot 1.5.X to Spring Boot 2.X and saw an issue with overriding Spring Bean definitions. One of the configurations was along these lines in Kotlin:@Configuration class DynamoConfig { @Bean fun dynamoDbAsyncClient(dynamoProperties: DynamoProperties): DynamoDbAsyncClient { ... } @Bean fun dynampoDbSyncClient(dynamoProperties: DynamoProperties): DynamoDbClient { ... } }Now, for a test I wanted to override these 2 bean definitions and did something along these lines:@SpringBootTest

javacodegeeks.com

Jib – Building docker image for a Spring Boot App

I was pleasantly surprised by how easy it was to create a docker image for a sample Spring Boot application using Jib.Let me first contrast Jib with an approach that I was using before.I was creating docker images using bmuschko’s excellent gradle-docker plugin. Given access to a docker daemon and a gradle dsl based description of the Dockerfile or a straight Dockerfile, it would create the

javacodegeeks.com

TestContainers and Spring Boot

TestContainers is just awesome! It provides a very convenient way to start up and CLEANLY tear down docker containers in JUnit tests. This feature is very useful for integration testing of applications against real databases and any other resource for which a docker image is available.My objective is to demonstrate a sample test for a JPA based Spring Boot Application using TestContainers. The sample is based on an example

javacodegeeks.com

Kotlin and JUnit 5 @BeforeAll

IntroductionIn Kotlin, classes do not have static methods. A Java equivalent semantic can be provided to callers using the concept of a companion object though. This post will go into details of what it takes to support a JUnit 5 @BeforeAll and @AfterAll annotation which depend on the precense of a static methods in test classes.BeforeAll and AfterAll in JavaJunit 5 @BeforeAll annotated methods are executed before all tests

javacodegeeks.com

Spring Boot 2 Applications and OAuth 2 – Setting up an Authorization Server

This will be a 3 post series exploring ways to enable SSO with an OAuth2 provider for Spring Boot 2 based applications. I will cover the following in these posts:1. Ways to bootstrap an OpenID Connect compliant OAuth2 Authorization Server/OpenID Provider.2. Legacy Spring Boot/Spring 5 approach to integrating with an OAuth2 Authorization Server/OpenID Provider.3. Newer Spring Boot 2/Spring 5 approach to integrating with

javacodegeeks.com

Kotlin – Reified type parameters sample

This post walks through a sample that demonstrates Kotlin’s ability to cleverly reify generic type parameters.So consider first a world where Kotlin does not support this feature, if we were using the Jackson library to convert a JSON to a Map with String based keys and Integer based values, I would use a code along these lines:@Test fun `sample parameterized retrieval raw object mapper`() { val objectMapper