Skip to content

Commit

Permalink
Documentation updation by rabbitcodeai (#1603)
Browse files Browse the repository at this point in the history
* Documentation updation by rabbitcodeai

* ai code review comments

* implement code review comments
  • Loading branch information
rajadilipkolli authored Dec 26, 2024
1 parent 7a94a26 commit 1cac5e3
Show file tree
Hide file tree
Showing 22 changed files with 378 additions and 156 deletions.
122 changes: 59 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# Spring Boot Integration Experiments

This repository contains a collection of sample projects and experiments showcasing various Spring Boot integrations and features. The goal is to help you explore new possibilities, demonstrate best practices, and learn advanced concepts in a unified space.

---

<!-- TOC -->
* [spring boot integration experiments](#spring-boot-integration-experiments)
* [Tech Stack](#tech-stack)
* [Useful Docker Commands](#useful-docker-commands)
* [Useful git Commands](#useful-git-commands)
* [Spring Boot Integration Experiments](#spring-boot-integration-experiments)
* [Overview](#overview)
* [Projects](#projects)
* [Tech Stack](#tech-stack)
* [Useful Docker Commands](#useful-docker-commands)
* [Useful git Commands](#useful-git-commands)
<!-- TOC -->

# spring boot integration experiments
---

## Overview

Each subdirectory in this repository demonstrates a focused aspect of Spring Boot development ranging from database integrations, caching, messaging, and multi-tenancy to advanced topics like Chaos Engineering and reactive stacks. Many of these samples are production ready, while some are still works-in-progress (WIP) intended for demonstration or experimentation.

**Key Features**:
1. **Wide Range of Integrations**: Explore different databases (MySQL, PostgreSQL, MongoDB, Oracle), caching with Redis, and advanced topics like multi-tenancy.
2. **Observability & Monitoring**: Many samples include Prometheus, Grafana, or Kibana. They demonstrate setting up and analyzing application performance in real time.
3. **Scalability & Resilience Patterns**: Investigate chaos monkey for injecting controlled failures, or look at multi-database solutions for horizontal scaling.

---
## Projects

Below is a quick lookup table summarizing each sub-project. For more details, check their individual README.md files.

The following table list all sample codes related to the spring boot integrations.

| Name | Description | Status |
|-------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
Expand Down Expand Up @@ -51,83 +71,59 @@ The following table list all sample codes related to the spring boot integration

For More info about this repository, Please visit [here](https://rajadilipkolli.github.io/my-spring-boot-experiments/)

### Tech Stack
Repo is built on the following main stack:

- <img width='25' height='25' src='https://img.stackshare.io/service/995/K85ZWV2F.png' alt='Java'/> [Java](https://www.java.com) – Languages
- <img width='25' height='25' src='https://img.stackshare.io/service/1209/javascript.jpeg' alt='JavaScript'/> [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) – Languages
- <img width='25' height='25' src='https://img.stackshare.io/service/2271/default_068d33483bba6b81ee13fbd4dc7aab9780896a54.png' alt='SQL'/> [SQL](https://en.wikipedia.org/wiki/SQL) – Languages
- <img width='25' height='25' src='https://img.stackshare.io/service/1011/n1JRsFeB_400x400.png' alt='Node.js'/> [Node.js](http://nodejs.org/) – Frameworks (Full Stack)
- <img width='25' height='25' src='https://img.stackshare.io/service/5807/default_cbd8ab670309059d7e315252d307d409aa40d793.png' alt='Project Reactor'/> [Project Reactor](https://projectreactor.io/) – Java Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/3881/da8da0c0e6dfbfc596f787ade49381a6_400x400.png' alt='QueryDSL'/> [QueryDSL](http://www.querydsl.com/) – Java Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/2006/spring-framework-project-logo.png' alt='Spring Framework'/> [Spring Framework](https://spring.io/projects/spring-framework) – Frameworks (Full Stack)
- <img width='25' height='25' src='https://img.stackshare.io/service/1021/lxEKmMnB_400x400.jpg' alt='jQuery'/> [jQuery](http://jquery.com/) – Javascript UI Libraries
- <img width='25' height='25' src='https://img.stackshare.io/service/21275/default_078eb0ae2b56280a937ed073a3ba4332291f9ba8.png' alt='Cloud DB for Mysql'/> [Cloud DB for Mysql](https://www.ncloud.com/product/database/cloudDbMysql) – SQL Database as a Service
- <img width='25' height='25' src='https://img.stackshare.io/service/3105/h2-logo_square_400x400.png' alt='H2 Database'/> [H2 Database](http://www.h2database.com/) – Databases
- <img width='25' height='25' src='https://img.stackshare.io/service/1398/y1As8_s5_400x400.jpg' alt='Liquibase'/> [Liquibase](https://www.liquibase.com) – Database Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/1615/mariadb-logo-400x400.png' alt='MariaDB'/> [MariaDB](https://mariadb.com/) – Databases
- <img width='25' height='25' src='https://img.stackshare.io/service/1027/sql_server.png' alt='Microsoft SQL Server'/> [Microsoft SQL Server](http://microsoft.com/sqlserver) – Databases
- <img width='25' height='25' src='https://img.stackshare.io/service/1030/leaf-360x360.png' alt='MongoDB'/> [MongoDB](http://www.mongodb.com/) – Databases
- <img width='25' height='25' src='https://img.stackshare.io/service/1025/logo-mysql-170x170.png' alt='MySQL'/> [MySQL](http://www.mysql.com) – Databases
- <img width='25' height='25' src='https://img.stackshare.io/service/1028/ASOhU5xJ.png' alt='PostgreSQL'/> [PostgreSQL](http://www.postgresql.org/) – Databases
- <img width='25' height='25' src='https://img.stackshare.io/service/1061/default_df93e9a30d27519161b39d8c1d5c223c1642d187.jpg' alt='RabbitMQ'/> [RabbitMQ](http://www.rabbitmq.com/) – Message Queue
- <img width='25' height='25' src='https://img.stackshare.io/service/1031/default_cbce472cd134adc6688572f999e9122b9657d4ba.png' alt='Redis'/> [Redis](http://redis.io/) – In-Memory Databases
- <img width='25' height='25' src='https://img.stackshare.io/service/11394/appsync.png' alt='Serverless AppSync'/> [Serverless AppSync](https://github.com/serverless-components/aws-app-sync) – GraphQL Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/7624/IG6D4Ro2_400x400.png' alt='Spring Data'/> [Spring Data](https://spring.io/projects/spring-data) – Database Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/2279/jooq-logo-white-750x750-padded.png' alt='jOOQ'/> [jOOQ](http://www.jooq.org) – Database Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/190/CvqrSSFs_400x400.jpg' alt='CircleCI'/> [CircleCI](https://circleci.com/) – Continuous Integration
- <img width='25' height='25' src='https://img.stackshare.io/service/586/n4u37v9t_400x400.png' alt='Docker'/> [Docker](https://www.docker.com/) – Virtual Machine Platforms & Containers
- <img width='25' height='25' src='https://img.stackshare.io/service/3136/docker-compose.png' alt='Docker Compose'/> [Docker Compose](https://github.com/docker/compose) – Container Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/2662/kWjFjx3K_400x400.jpg' alt='FindBugs'/> [FindBugs](http://findbugs.sourceforge.net/) – Code Review
- <img width='25' height='25' src='https://img.stackshare.io/service/11563/actions.png' alt='GitHub Actions'/> [GitHub Actions](https://github.com/features/actions) – Continuous Integration
- <img width='25' height='25' src='https://img.stackshare.io/service/975/gradlephant-social-black-bg.png' alt='Gradle'/> [Gradle](https://www.gradle.org/) – Java Build Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/2645/default_8f9d552b144493679449b16c79647da5787e808b.jpg' alt='Grafana'/> [Grafana](http://grafana.org/) – Monitoring Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/670/jenkins.png' alt='Jenkins'/> [Jenkins](http://jenkins-ci.org/) – Continuous Integration
- <img width='25' height='25' src='https://img.stackshare.io/service/1722/Image_2019-05-20_at_4.53.31_PM.png' alt='Kibana'/> [Kibana](https://www.elastic.co/kibana) – Monitoring Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/2923/05518ecaa42841e834421e9d6987b04f_400x400.png' alt='Logback'/> [Logback](https://logback.qos.ch/) – Log Management
- <img width='25' height='25' src='https://img.stackshare.io/service/10079/loki.png' alt='Loki'/> [Loki](https://github.com/grafana/loki) – Logging Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/2501/default_3cf1b307194b26782be5cb209d30360580ae5b3c.png' alt='Prometheus'/> [Prometheus](http://prometheus.io/) – Monitoring Tools
- <img width='25' height='25' src='https://img.stackshare.io/service/3276/xWt1RFo6_400x400.jpg' alt='Apache Camel'/> [Apache Camel](https://camel.apache.org/) – Platform as a Service
- <img width='25' height='25' src='https://img.stackshare.io/service/6429/alpine_linux.png' alt='Alpine Linux'/> [Alpine Linux](https://www.alpinelinux.org/) – Operating Systems
- <img width='25' height='25' src='https://img.stackshare.io/service/3633/ZBMmmvP1_400x400.jpg' alt='Base'/> [Base](https://getbase.com/) – CRM
- <img width='25' height='25' src='https://img.stackshare.io/service/841/Image_2019-05-20_at_4.58.04_PM.png' alt='Elasticsearch'/> [Elasticsearch](https://www.elastic.co/products/elasticsearch) – Search as a Service
- <img width='25' height='25' src='https://img.stackshare.io/service/4631/default_c2062d40130562bdc836c13dbca02d318205a962.png' alt='Shell'/> [Shell](https://en.wikipedia.org/wiki/Shell_script) – Shells

Full tech stack [here](/techstack.md)

### Useful Docker Commands

> Start postgres and pgadmin
---

## Tech Stack

This repository leverages a broad stack of technologies, including:

- **Java** / **JavaScript** / **SQL** for core logic & data.
- **Spring Framework** (Boot, Data, Security, etc.) as the key application framework.
- **Project Reactor** for reactive data flows and concurrency.
- **QueryDSL**, **Liquibase**, **Flyway**, **JOOQ** for advanced database interactions and migrations.
- **Docker**, **Docker Compose** for containerization and multi-service orchestration.
- **RabbitMQ**, **Redis**, **Elasticsearch**, **OpenSearch**, **MongoDB** for messaging, caching, and search.
- **Gradle** / **Maven** for builds and dependency management.
- **GitHub Actions**, **CircleCI**, **Jenkins** for CI/CD pipelines.

For in-depth version references, visit [techstack.md](/techstack.md) or see individual project READMEs.

---

## Useful Docker Commands

Start postgres and pgadmin
```shell
docker compose up postgres pgadmin4
```
> Clean up everything using
Clean up everything using
```shell
docker system prune -a -f --volumes
```
> Claim unused volumes
Claim unused volumes
```shell
docker volume prune
```
> Running container
Running container
```shell
docker container ls
```

### Useful git Commands
---

## Useful git Commands

How to overwrite local changes with git pull

> Stash local changes:
Stash local changes:
```shell
$ git stash
git stash
```
> Pull changes from remote:
Pull changes from remote:
```shell
$ git pull
git pull
```

How to revert the changes that are pushed to remove
```shell
$ git revert $hash
git revert $hash
```
23 changes: 20 additions & 3 deletions boot-chaos-monkey/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# spring-boot-chaos-monkey
# Spring Boot Chaos Monkey

[Choas Monkey](https://netflix.github.io/chaosmonkey/)

This module explores Chaos Engineering principles by intentionally injecting failures into a Spring Boot application to test its resilience. It demonstrates how to set up and integrate `chaos-monkey-spring-boot` for your microservices, as well as performance testing with Gatling to measure any degradation under chaos scenarios.


![](../images/chaos-monkey.png)

The idea behind this API is to show some of the possible ways to introduce Chaos Engineering principles in a project. It adds Gatling performance tests to demonstrate how adding assaults will cause delays in response time and verify that chaos monkey is working as expected.
---

## Key Features

1. **Chaos Injection**: Simulate random latencies, exceptions, or resource unavailability.
2. **Performance Testing** (Gatling): Benchmark throughput and latency under chaotic conditions.
3. **Monitoring**: Validate that chaos is functioning by observing logs, metrics, or custom dashboards.

Using Springframework 6.0 `ProblemDetails` and spring boot micrometer Observability in controller
---


### Run tests

```shell
Expand All @@ -31,6 +40,14 @@ docker-compose -f docker/docker-compose.yml up -d
./mvnw gatling:test
```

**Verification**:

* Check application logs for entries containing "Chaos Monkey" to confirm injection events
* Use Gatling or other load testing tools to measure:
* Response time degradation
* Error rate changes
* System resource utilization

By default, Chaos Monkey is enabled. Let's disable it and run the tests again. It should improve the response times.

```shell
Expand Down
20 changes: 17 additions & 3 deletions boot-mongodb-elasticsearch/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# boot-mongodb-elasticsearch
# MongoDB and Elasticsearch Reactive Integration

Integrates a reactive MongoDB backend with a reactive Elasticsearch instance for enhanced real-time searching capabilities, including geospatial queries.

---

## Highlights

- **Reactive Streams Approach**: Uses Spring Data’s reactive driver for both MongoDB and Elasticsearch.
- **Advanced Queries**: Demonstrates geospatial searches, text-indexed searches, and filtering in near real-time.
- **Scalable Architecture**: Docker-compose-based environment for local testing.

---

### Run tests

Expand All @@ -12,7 +24,6 @@ docker-compose -f docker/docker-compose.yml up -d
./mvnw spring-boot:run -Dspring-boot.run.profiles=local
```


### Useful Links
* Swagger UI: http://localhost:8080/swagger-ui.html
* Actuator Endpoint: http://localhost:8080/actuator
Expand All @@ -22,6 +33,8 @@ docker-compose -f docker/docker-compose.yml up -d
* Elasticsearch : http://localhost:9200/
* MongoExpress : http://localhost:8081

---

## Mongodb Notes

Transactions with `ReactiveMongoTransactionManager`
Expand All @@ -44,8 +57,9 @@ public class DataStoreConfiguration extends AbstractReactiveMongoConfiguration {
}
}
```
---

## Elastic Search Notes
## Elasticsearch Notes

### UseFull ElasticSearch Commands
- Count http://localhost:9200/restaurant/_count
Expand Down
27 changes: 24 additions & 3 deletions boot-opensearch-sample/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
# boot-opensearch-sample
# OpenSearch Integration

Showcases saving data and performing swift geospatial or text-based searches in OpenSearch as an alternative to Elasticsearch.

---
## Key Features

- **OpenSearch Client**: Illustrates setting up a Spring Boot app to send documents to an OpenSearch cluster.
- **Geospatial Queries**: Provides examples of storing and querying location-based data.
- **High Throughput**: Demonstrates efficient indexing and search operations.

---

### **Querying**

You can use either:

* Swagger UI for built-in endpoints.
* OpenSearch Dashboards for manual searching.

---


### Format code

```shell
$ ./mvnw spotless:apply
./mvnw spotless:apply
```

### Run tests

```shell
$ ./mvnw clean verify
./mvnw clean verify
```

### Run locally
Expand Down
18 changes: 14 additions & 4 deletions boot-rabbitmq-thymeleaf/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# SpringBoot Messaging with RabbitMQ
# Spring Boot with RabbitMQ & Thymeleaf

Demonstrates a message producer and consumer setup with RabbitMQ, plus a simple Thymeleaf UI for administrative or demonstration purposes.

---

## Key Features

- **Producer Confirmations & DLQ**: Ensures reliable delivery with Dead Letter Queues.
- **Thymeleaf UI**: A minimal interface to view or publish messages.
- **Spring AMQP**: Streams events, allowing asynchronous processing.

---

Source Code : https://sivalabs.in/2018/02/springboot-messaging-rabbitmq/

Expand All @@ -14,6 +26,4 @@ Windows
# Important links

Home Page : http://localhost:8080
RabbitMq : http://localhost:15672


RabbitMq : http://localhost:15672 (guest/guest default)
10 changes: 6 additions & 4 deletions boot-togglz-sample/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# boot-togglz-sample
# Feature Toggles With Togglz

Demonstrates using the [Togglz](https://www.togglz.org/) library for feature toggling in a Spring Boot application, enabling features to be turned on/off without redeploys.

The toggle feature in a Spring Boot application is a mechanism that allows the developer to enable or disable certain features of the application without having to restart the entire application. This is useful for testing and debugging purposes, as it allows the developer to quickly enable or disable certain features without having to go through the time-consuming process of restarting the application. The toggle feature can be accessed through the application's configuration files, where the developer can specify which features should be enabled or disabled.

A Feature can be enabled using strategy like date, profile, username, etc. As of now 13 strategies are supported by togglz.

### Run tests
`$ ./mvnw clean verify`
`./mvnw clean verify`

### Run locally
```
$ docker-compose -f docker/docker-compose.yml up -d
$ ./mvnw spring-boot:run -Dspring-boot.run.profiles=local
docker-compose -f docker/docker-compose.yml up -d
./mvnw spring-boot:run -Dspring-boot.run.profiles=local
```


Expand Down
31 changes: 27 additions & 4 deletions boot-ultimate-redis/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
# boot-ultimate-redis
This is an example repository to discover ways of interacting with Redis (from a Spring Boot 3 Application).
# Ultimate Redis Implementation

![Spring Boot Redis](https://github.com/programmerfriend/programmerfriend.github.io/blob/master/img/content/robust-boot_title.png?raw=true "Spring Boot Redis")

A comprehensive sample showcasing various Redis usage patterns, including sentinel architecture, advanced TTL management, and cluster connections.

## Redis Sentinel & High Availability

- Runs 1 master, 1 replica, and 3 sentinel instances via Docker Compose.
- **Quorum** Setting (defaults to 2) for failover decisions.

## ReadFrom Settings

Configurable with Lettuce through application properties:

```yaml
spring:
redis:
lettuce:
read-from: REPLICA_PREFERRED
```
Available options: MASTER, REPLICA_PREFERRED, MASTER_PREFERRED, etc.
---
## View Keys using cli
Connect to redis-cli using below command
Expand Down Expand Up @@ -67,5 +88,7 @@ We will run 1 master,1 slave and 3 sentinel instance.
We are using _REPLICA_PREFERRED_ in here but this configuration can be important in production!

### Reference
- [medium](https://medium.com/@htyesilyurt/spring-boot-3-redis-sentinel-lettuce-client-and-docker-compose-for-high-availability-1f1e3c372a5a)
- [programmerfriend](https://programmerfriend.com/ultimate-guide-to-redis-cache-with-spring-boot-2-and-spring-data-redis/)
### Reference
- [Spring Boot 3 Redis Sentinel Guide](https://medium.com/@htyesilyurt/spring-boot-3-redis-sentinel-lettuce-client-and-docker-compose-for-high-availability-1f1e3c372a5a)
- [Ultimate Guide to Redis Cache](https://programmerfriend.com/ultimate-guide-to-redis-cache-with-spring-boot-2-and-spring-data-redis/)

Loading

0 comments on commit 1cac5e3

Please sign in to comment.