Skip to content

Spring Boot 2 with Spring Cloud Stream Kafka (Consumer/Producer) And RabbitMQ (Consumer/Producer) and React Application And Email

Notifications You must be signed in to change notification settings

ricardo-ribeiro/SpringBootWebRabbitMQAndKafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Web & Data & RabbitMQ & Kafka

Java CI

!! WIP !!

In This Repository

A Example Spring Boot Application

A Example React Application

Dockerized Services

Start React Development Server

cd ui 
npm install
npm start

GO TO UI ON DEVELOPMENT SERVER

GO TO BUILT_UI ON SPRING BOOT SERVER

Proxyed Requests : htto://localhost:3000 : http://localhost:5757

MariaDB DataSource - Spring Data

A Kafka Spring Cloud Binder

With a Consumer

With a Producer

A RabbitMQ Spring Cloud Binder

With a Consumer

With a Producer

A REST Api

With Spring Security

Basic

JWT

Docker Services

ADMINER

Web Application MYSQL/MariaDB database explorer. Allows you to run queries and manage your database.

Host: http://localhost:9999
Server: mariadb
Username: root
Password: root
Database: Empty OR ExampleDatabase

GO TO ADMINER

Adminer Image

Adminer Image

RabbitMQ Management Console

RabbitMQ Management Console

RabbitMQ is an open-source message-broker software (sometimes called message-oriented middleware) that originally implemented the Advanced Message Queuing Protocol (AMQP) and has since been extended with a plug-in architecture to support Streaming ... (Wikipedia)

Host: http://localhost:15672
Username: guest
Password: guest

RabbitMQ Management Console

RabbitMQ Image

RabbitMQ Console Image

RabbitMQ

Kafka

Zookeeper

Running Docker Services

cd docker
docker-compose up

Running the Application

./gradlew build bootRun

Configuration

  • Default Port: 5757

./src/main/resources/application.yml

server:
  port: 5757 // Set the Server Port

logging.level.root: INFO // Set the root Logging Level ex.: INFO | DEBUG | TRACE
logging.level.<classpath>.<name>: INFO // INFO | DEBUG ...

# Use When Having Spring Actuator, Expose All Endpoints {Security Concerns}
management:
  endpoints:
    web:
      exposure:
        include: "*" # Expose All The Actuator Endpoints

# When Using spring.security.xtype: JWT ; You Can Customise The token Generation
# key paths and other details.
custom:
  security:
    masterUser:
      username: master@localhost.com
      password: root
      roles:
        - MASTER
        - DEVELOPER
        - CUSTOMER
    jwt:
      header:
        key: Authorization
        value:
          prefix: Bearer
      algorithm : RSA512
      token:
        aliveFor: 3600
        issuer: ExampleApplication@localhost
        audience:
          - banana
          - banana1
          - banana2
        scope:
          - ui
      keys:
        public:
          path: /banana
        private:
          path: /banana


spring:
  # Spring Security Details
  security:
    xtype: BASIC # custom: BASIC or JWT
    user:
      name: root
      password: root
  # Spring Data Default Data Source - MariaDB
  datasource:
    url: jdbc:mariadb://localhost:3306/ExampleDatabase
    username: root
    password: root
    driver-class-name: org.mariadb.jdbc.Driver
    validationQuery: SELECT 1
  application:
    name: ExampleApp
  h2:
    console:
      enabled: true
  # Spring Cloud Streams Binder and Bindings Details
  cloud:
    stream:
      defaultBinder: rabbit
      bindings:
        globalEventsInput:
          binder: kafka
          destination: global_events
          content-type: application/json
          group: input-group-1
        globalEventsOutput:
          binder: kafka
          destination: global_events
          group: output-group-1
          content-type: application/json
        paymentsReceived:
          binder: rabbit
          destination: queue.payment.received
          group: payments
        paymentValidated:
          binder: rabbit
          destination: queue.payment.validated
          group: payments

      binders:
        kafka:
          type: kafka
          environment:
            spring.cloud.stream.kafka:
              binder:
                brokers: localhost
                defaultBrokerPort: 9092
              # Specific Internal Kafka Consumer and Producer Properties per Binding
              bindings:
                globalEventsOutput:
                  producer:
                    configuration:
                      key.serializer: org.apache.kafka.common.serialization.StringSerializer
                globalEventsInput:
                  consumer:
                    configuration:
                      isolation.level: read_committed # In case of Transactional Produced, Otherwise read_uncommitted
        rabbit:
          type: rabbit
          environment:
            spring:
              cloud:
                stream:
                  rabbit:
                    # Specific Internal RabbitMQ Consumer and Producer Properties per Binding
                    bindings:
                      paymentsReceived:
                        consumer:
                          autoBindDlq: true
                          requeueRejected: true
                          republishToDlq: true
                      paymentValidated:
                        producer:
                          autoBindDlq: true
                          republishToDlq: true
              rabbitmq:
                host: localhost
                port: 5672
                username: guest
                password: guest