Logo

dev-resources.site

for different kinds of informations.

Introducing Java Library for Backend Microservice Webflux (Reactor-core)

Published at
1/12/2025
Categories
java
backend
reactorcore
webflux
Author
hoangtien2k3
Categories
4 categories in total
java
open
backend
open
reactorcore
open
webflux
open
Author
12 person written this
hoangtien2k3
open
Introducing Java Library for Backend Microservice Webflux (Reactor-core)

Image description

Link github: https://github.com/hoangtien2k3/reactify-core

1. Library Overview

This library is built on the core components of Spring WebFlux and Reactor-Core – two powerful tools supporting reactive programming. With this library, you can easily build asynchronous microservice applications, handling non-linear data streams efficiently.

Highlight features include:

  • Full reactive programming support: Stream-based asynchronous data processing.
  • High performance optimization: Minimize the number of threads needed and maximize CPU resources.
  • Easy scalability: Suitable for microservice systems that require handling large volumes of requests from users.

2. Advantages of the library

  1. High performance and good responsiveness:
    Using a non-blocking mechanism, this library can handle thousands of concurrent requests without creating too many threads, which reduces resource load and improves response speed.

  2. Easy stream processing:
    Reactor-Core provides a powerful API for stream processing, suitable for applications that need to process continuous data such as real-time notification systems, event processing, and big data processing systems.

  3. Easy integration with the Spring ecosystem:
    The library is designed to work well with components in the Spring ecosystem such as Spring Security, Spring Data R2DBC, helping to build complete applications with less effort.

Image description

Setup reactify-core

1. Use annotation @ComponentScan to scan all libraries

@ComponentScan(basePackages = {
        "com.reactify.*",           // add default: com.reactify.*
        "com.example.myproject"     // varies depending on your project
})
@SpringBootApplication
public class ExampleApplication {
    public static void main(String[] args) {
        SpringApplication.run(Example.class, args);
    }
}
Enter fullscreen mode Exit fullscreen mode

2. Config your project file application.yml or application.properties

# spring config
spring:
  main:
    web-application-type: reactive
    allow-bean-definition-overriding: true
  messages:
    basename: i18n/messages

  #connect db R2DBC PostgreSQL
  r2dbc:
    url: r2dbc:postgresql://localhost:5434/auth
    username: admin
    password: admin
    pool:
      max-size: 10
      initial-size: 5

  # Config connect Keycloak
  security:
    oauth2:
      client:
        provider:
          oidc:
            token-uri: ${keycloak.serverUrl}/realms/${keycloak.realm}/protocol/openid-connect/token
        registration:
          oidc:
            client-id: ${keycloak.clientId}
            client-secret: ${keycloak.clientSecret}
            authorization-grant-type: ${keycloak.grantType} #password || #client_credentials
      resourceserver:
        jwt:
          jwk-set-uri: ${keycloak.serverUrl}/realms/${keycloak.realm}/protocol/openid-connect/certs
      keycloak:
        client-id: ${keycloak.clientId}

# Web client config
client:
  #keycloak
  keycloak:
    address: http://localhost:8080/realms/ezbuy-server/protocol/openid-connect
    name: keycloak
    auth:
      client-id: ezbuy-client
      client-secret: mI92QDfvi20tZgFtjpRAPWu8TR6eMHmw
  #notification
  notification:
    internal-oauth: true
    address: http://localhost:7777/v1/transmission
    name: notiServiceClient
    pool:
      max-size: 100
      max-pending-acquire: 100
    timeout:
      read: 60000
      write: 1000

# Unauthenticated endpoints config
application:
  http-logging:
    request:
      enable: true
      header: true
      param: true
      body: true
    response:
      enable: true
      body: true
  whiteList:
    - uri: /v1/auth/generate-otp
      methods:
        - POST
    - uri: /**
      methods:
        - OPTIONS
    - uri: /v1/auth/get-all
      methods:
        - GET
  data:
    sync-data:
      limit: 500

#keycloak client config
keycloak:
  clientId: ezbuy-client
  clientSecret: mI92QDfvi20tZgFtjpRAPWu8TR6eMHmw
  realm: ezbuy-server
  serverUrl: http://localhost:8080
  grantType: password
  host: localhost

# minio server config
minio:
  bucket: ezbuy-bucket
  enabled: true
  baseUrl: http://localhost:9000
  publicUrl: http://localhost:9000/ezbuy-bucket
  accessKey: 4DoaZ0KdzpXdDlVK104t
  secretKey: nuRiQUIJNVygMOHhmtR4LT1etAa7F8PQOsRGP5oj
  private:
    bucket: ezbuy-private
Enter fullscreen mode Exit fullscreen mode

3. After completing the configuration, start running the project.

  # Using Maven
  mvn spring-boot:run

  # Using Gradle
  gradle bootRun
Enter fullscreen mode Exit fullscreen mode

4. Refer to the following project, used

reactify-core library for webflux microservice project: keycloak-auth-service

Everyone can give feedback and find errors or improve this library to help develop the community stronger, thank you very much
Have a nice day

backend Article's
30 articles in total
Favicon
Singularity: Streamlining Game Development with a Universal Framework
Favicon
5 Tools Every Developer Should Know in 2025
Favicon
Preventing SQL Injection with Raw SQL and ORM in Golang
Favicon
Como redes peer-to-peer funcionam?
Favicon
🌐 Building Golang RESTful API with Gin, MongoDB 🌱
Favicon
[Boost]
Favicon
What is Quartz.Net and its simple implementation
Favicon
tnfy.link - What's about ID?
Favicon
Construindo uma API segura e eficiente com @fastify/jwt e @fastify/mongodb
Favicon
Desbravando Go: Capítulo 1 – Primeiros Passos na Linguagem
Favicon
Understanding Spring Security and OAuth 2.0
Favicon
RabbitMQ: conceitos fundamentais
Favicon
Mastering Java: A Beginner's Guide to Building Robust Applications
Favicon
Mastering Backend Node.js Folder Structure, A Beginner’s Guide
Favicon
Setting Up Your Go Environment
Favicon
Introducing Java Library for Backend Microservice Webflux (Reactor-core)
Favicon
SQL Injection - In Just 5 Minutes!
Favicon
10 Backend Terms Every Frontend Developer Should Know
Favicon
How Do You Use Encapsulation with Micronaut Annotations?
Favicon
Building Streak Calendar: My Journey into Open-Source with the Help of AI
Favicon
Authentication System Using NodeJS
Favicon
Digesto: A Lightning-Fast Way to Build Backends with YAML
Favicon
dotnet терминал команды
Favicon
My Study Schedule for 2025
Favicon
Building Microservices with Node.js: An Introduction
Favicon
Great resource for backend developers
Favicon
[Boost]
Favicon
6 Best Practices Every Backend Dev Should Know
Favicon
Building Type-Safe APIs: Integrating NestJS with Prisma and TypeScript
Favicon
The Secret Weapon Against API Abuse: The Power of Rate Limiting

Featured ones: