search
HomeJavajavaTutorialIntroducing Java Library for Backend Microservice Webflux (Reactor-core)

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

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.

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

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);
    }
}

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

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

  # Using Maven
  mvn spring-boot:run

  # Using Gradle
  gradle bootRun

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

The above is the detailed content of Introducing Java Library for Backend Microservice Webflux (Reactor-core). For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution?How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution?Mar 17, 2025 pm 05:46 PM

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

How do I create and use custom Java libraries (JAR files) with proper versioning and dependency management?How do I create and use custom Java libraries (JAR files) with proper versioning and dependency management?Mar 17, 2025 pm 05:45 PM

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache?How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache?Mar 17, 2025 pm 05:44 PM

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading?How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading?Mar 17, 2025 pm 05:43 PM

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

How does Java's classloading mechanism work, including different classloaders and their delegation models?How does Java's classloading mechanism work, including different classloaders and their delegation models?Mar 17, 2025 pm 05:35 PM

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),