Posts

Showing posts from January, 2023

How to add Resiliency to any APIs

Resiliency Handler Resiliency Handler This simple generic class helps to add resiliency to any APIs with follow delay strategies Exponential backoff and jitter strategy. Fixed delay strategy. ResiliencyHandler.java package circuitbreaker; import lombok.extern.slf4j.Slf4j; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; /** * Generic ResiliencyHandler to simplify retry operations with fixed/exponential * backoff delay strategies * * <pre> * Student student = * ResiliencyHandler.buildFor(Student.class) * .usingJitterStrategy(3, 10L * 1000L) * .tryWithResiliency(() -> studentService.getStudent()) * .fallbackOnFail(() -> studentService.getDefaultStudent()) * .getResult();// return result * * </pre> * * @param <R> ResultType * * @author ThirupathiReddy Vajjala */ @Slf4j public class R

Switch JDK Versions in Linux

Switching JDK Versions Switching JDK Versions If you want to switch between different JDK major versions that are available Try below command, choose option switch.sh $/> alternatives --config java There is 1 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-1.el7_9.x86_64/jre/bin/java) Enter to keep the current selection[+], or type selection number: 1 If you want to install new version new.sh yum install java-11-openjdk-devel Loaded plugins: tsflags, versionlock Resolving Dependencies --> Running transaction check ---> Package java-11-openjdk-devel.x86_64 1:11.0.19.0.7-1.0.1.el7_9 will be installed --> Processing Dependency: java-11-openjdk(x86-64) = 1:11.0.19.0.7-1.0.1.el7_9 for package: 1:java-11-openjdk-devel-11.0.19.0.7-1.0.1.el7_9.x86_64 --> Running transaction check ---> P