Wednesday, 27 January 2021

Useful kafka commands

For past few months I have been working with many kafka production issues and I am still trying to learn many new things about it. But while working on any kafka issue, you always want some commands to be very handy and just one click away in a file or in a blog.

Here are few kafka commands that may be very helpful to you while learning or solving any of your kafka issues. 

Here I would be referring KAFKA_HOME as your path to kafka home.

Saturday, 11 July 2020

Hystrix Circuit breaker in Java Spring

In this blog I will be dicussing about Hystrix as a circuit breaker in java. First of all we should understand what is circuit breaker and why to use it in a distributed environment.

Netflix's Hystrix library provides an implementation of the circuit breaker pattern. When you apply a circuit breaker to a method, Hystrix watches for failing calls to that method, and, if failures build up to a threshold, Hystrix opens the circuit so that subsequent calls automatically fail.

Monday, 19 February 2018

Best way to use @OneToOne in Hibernate

Creating a proper hibernate entity relationship design is one of the difficult task of projects. There are multiple factors that you need to consider while making relationships in entities. You must have proper domain or business knowledge of your project to perform these tasks.

Below factors affects the execution of relationship :
  • Object Fetching strategies
  • Lazy-Eager fetching
  • Performance tuning
  • Making the right table as Owner of relationship
  • Unidirectional or Bidirectional relationship

You need to consider all these factors while creating hibernate entity relationships.

In this blog I will be talking about @OneToOne mapping in Hibernate. I will be explaining two different examples of @OneToOne to understand its lazy feature.

Case 1 : Worker - WorkerProfile relation
Case 2 : Manager - ManagerProfile relation

Thursday, 16 March 2017

Functional Programming in java

Java 8 introduced a new feature called lambda expressions. Before Java 8 it only followed object oriented programming and its concepts. Now it has allowed to write functional programming as well by passing code as an argument to a method. Functional programming is a hot topic for some other programming languages.  But Java doesn't had any feature like that before java 8.
In this blog I will try to cover following topics:
  1. Lambda expression
  2. Functional interface
  3. Variable capture
  4. Method References
  5. Default method
Before starting anything, lets come to questions of WHY and then HOW.

Monday, 13 February 2017

Introduction to AbstractQueuedSynchronizer in java

For managing multi-threading applications, java follows monitor construct. According to Monitor construct if a thread is executing a critical section while holding mutex (or intrinsic lock) of an object, no other thread can execute this critical section with lock of same object. synchronized method and synchronized block are simple implementation of this technique.Many concepts of Semaphore and latches are implemented in java over this concept. All concurrent classes introduced in java 1.5 like ReentrantLock, ThreadPoolExecutor and many others are based on this technique. There are times when we require either to wait a thread or to start running a thread, based on the state of an object. Thread can sleep/wait/run depending on some conditions. These types of classes are known as state dependent classes.