Posts

Event Driven Architecture

 What is Event Driven Architecture? Discover what is event driven architecture, its core components, benefits, and real-world examples in this comprehensive guide. Event-driven architecture (EDA) is a software design pattern where systems communicate by producing and reacting to events, such as a user placing an order or a sensor detecting a temperature change. Instead of repeatedly checking for updates (request-driven), EDA provides instant notifications when an event occurs, enabling a responsive and asynchronous flow of information. Understanding Event Driven Architecture in Practice To understand EDA's distinction, compare it to a traditional request-response system where one service directly calls another and waits for a reply, creating dependencies. If the called service is slow or unresponsive, the process halts. In contrast, event-driven architecture broadcasts events like UserLoggedIn or PaymentProcessed, allowing other services to listen and react independently, without t...

Java 8 Specific Best Practices to secure Application

Use of Optional Keyword 5.1 What Optional is? ‘Optional’ is a keyword introduced in Java8 which has the potential of removing the in-famous NullPointerException. Essentially, it is a wrapper class which contains an optional value and hence it can either contain an object or it can be empty. Lets start using a simple use case where in we see that before Java 8, any number of operations involving accessing an object’s methods or properties could lead to a NullPointerException. A classic example of this is –  String ISBNNumber = book.getPublisher().getISBN().toUpperCase(); If we want to ensure that we don’t get the NullPointerException then we need to write our code as under –  if (book != null) { Publisher publisher = book.getPublisher(); If (publisher != null) { String isBNNumber = publisher.getISBN(); If (isBNNumber != null) { String ISBNNumber = isBNNumber.toUpperCase(); } } } As seen above, if we want to ensure that there is no NullPointerException we ne...

Mastering Reactive Programming with Project Reactor in Java

  1. Introduction Reactive Programming is an asynchronous programming paradigm focused on handling data streams and event-driven applications. It enables non-blocking execution, efficient resource utilization, and responsiveness, making it ideal for modern applications that require scalability and real-time processing. Java provides the java.util.concurrent package for handling concurrency, but it lacks a standard for asynchronous, event-driven programming. To address this, the Reactive Streams Specification was introduced, and libraries like Project Reactor were built on top of it to enable reactive programming. 2. Reactive Streams Specification The Reactive Streams Specification defines a standard for asynchronous stream processing with backpressure. It consists of four key interfaces: Publisher : Emits a stream of data to its subscribers. Subscriber : Receives data and handles it accordingly. Subscription : Manages the lifecycle between the publisher and subscriber. Processor...

Enhancing a Banking Platform: By Using BFF + DDD + Hexagonal + CQRS to a Modern, Resilient Architecture

  This article proposes concrete upgrades to improve scalability, resilience, security, developer velocity, and compliance—tailored for banking workloads. 1) Clarify and Strengthen Each Layer’s Responsibility BFF (per-channel): Keep request/response models channel-specific; avoid leaking domain objects. Consider GraphQL at the BFF or an Aggregation/Composition layer for flexible, low‑chattiness mobile experiences. Add schema validation (JSON Schema/Avro), rate limits , and adaptive throttling per channel and client. Domain Services (DDD + Hexagonal): Enforce Ports & Adapters strictly: inbound (HTTP/Events) and outbound (repositories, external services) are adapter-only. Promote aggregates with clear invariants and domain events as first‑class citizens. Align bounded contexts with business capabilities (Payments, Accounts, Onboarding, Cards, UPI, Loans, KYC). Proxy Layer → Anti‑Corruption Layer (ACL): Rename to ACL to emphasize translation, normalization, and idempotency...

Enhancements in Java 21 for Concurrency — A Leap Toward Simplicity with Virtual Threads

๐Ÿงต Enhancements in Java 21 for Concurrency — A Leap Toward Simplicity with Virtual Threads ๐Ÿ”— Related Reads: Enhancements in Java 5 for Concurrency Enhancements in Java 8 for Concurrency Java has evolved significantly over the last two decades—from manual thread management in Java 5, to asynchronous computation via CompletableFuture in Java 8, and now, in Java 21 , a major shift with Virtual Threads under Project Loom. Let’s explore how Java 21 revolutionizes concurrency by making it simpler and more scalable without requiring complicated constructs. ๐Ÿ“Œ What Are Virtual Threads? Virtual Threads are lightweight, OS-independent threads managed by the JVM rather than the operating system. Unlike traditional (platform) threads, millions of virtual threads can run concurrently with minimal memory and scheduling overhead. ๐Ÿ”„ Evolution at a Glance Feature Java 5 Java 8 Java 21 Task Management Executors, Thread pools CompletableFuture Virtual Threa...

Enhancements in Java 8 for Concurrency and Multithreading

  Enhancements in Java 8 for Concurrency and Multithreading Java 8 introduced several enhancements and new features to improve concurrency and multithreading. Among these, CompletableFuture stands out as a powerful tool for asynchronous programming. This post explores the key additions in Java 8 related to concurrency, including CompletableFuture , runAsync() , supplyAsync() , and other notable features. CompletableFuture CompletableFuture is a class that implements the Future interface and provides a flexible way to handle asynchronous computation. It allows you to write non-blocking code and provides a variety of methods to create, combine, and process asynchronous tasks. Key Methods runAsync() The runAsync() method is used to run a task asynchronously without returning any result. CompletableFuture<Void> future = CompletableFuture.runAsync(() -> { // Task to run asynchronously }); supplyAsync() The supplyAsync() method is used to run a task asynchronously that...

Embracing Functional Programming in Java

  Java 8 New Features: Embracing Functional Programming in Java Java 8 marked a significant shift in the Java programming language by introducing powerful features that embraced functional programming paradigms, enhanced API design, and simplified coding practices. In this post, we explore the major features introduced in Java 8 and how they revolutionized the Java ecosystem. Key Features in Java 8 Lambda Expressions Functional Interfaces Method References Default Methods Optional Stream API Lambda Expressions Lambda expressions provide a concise way to represent functional interfaces (interfaces with a single abstract method). This enables passing functionality as an argument to methods. Syntax: (parameter1, parameter2) -> expression Examples: (int x, int y) -> x + y () -> 42 (String s) -> { System.out.println(s); } Example - Runnable Lambda: Runnable r = () -> System.out.println("Hello from lambda"); new Thread(r).start(); Advantages: Reduces boilerplate code...