{"id":17028379,"url":"https://github.com/gazbert/spring-boot-rabbit-app","last_synced_at":"2026-01-18T17:33:28.854Z","repository":{"id":53278675,"uuid":"255705770","full_name":"gazbert/spring-boot-rabbit-app","owner":"gazbert","description":"A Spring Boot sample app that uses RabbitMQ and shows how to test it.","archived":false,"fork":false,"pushed_at":"2022-11-16T02:42:23.000Z","size":225,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T20:43:23.431Z","etag":null,"topics":["checkstyle","gradle","jacoco","java","maven","rabbitmq","sample-app","spotbugs","spring-amqp","spring-boot","testcontainers"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gazbert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-14T19:28:15.000Z","updated_at":"2021-09-17T16:41:16.000Z","dependencies_parsed_at":"2023-01-23T08:15:12.420Z","dependency_job_id":null,"html_url":"https://github.com/gazbert/spring-boot-rabbit-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gazbert/spring-boot-rabbit-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazbert%2Fspring-boot-rabbit-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazbert%2Fspring-boot-rabbit-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazbert%2Fspring-boot-rabbit-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazbert%2Fspring-boot-rabbit-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gazbert","download_url":"https://codeload.github.com/gazbert/spring-boot-rabbit-app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gazbert%2Fspring-boot-rabbit-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28544897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T14:59:57.589Z","status":"ssl_error","status_checked_at":"2026-01-18T14:59:46.540Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checkstyle","gradle","jacoco","java","maven","rabbitmq","sample-app","spotbugs","spring-amqp","spring-boot","testcontainers"],"created_at":"2024-10-14T07:53:54.706Z","updated_at":"2026-01-18T17:33:28.824Z","avatar_url":"https://github.com/gazbert.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Boot Rabbit App\n\n[![Build Status](https://travis-ci.org/gazbert/spring-boot-rabbit-app.svg?branch=master)](https://travis-ci.org/gazbert/spring-boot-rabbit-app)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=gazbert_spring-boot-rabbit-app\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=gazbert_spring-boot-rabbit-app)\n\n## What is this?\nA [Spring Boot](http://projects.spring.io/spring-boot/) sample app (and learning exercise!) \nthat integrates [RabbitMQ](https://www.rabbitmq.com/) using [Spring AMQP](https://spring.io/projects/spring-amqp).\n\nIt could be used as boilerplate for developing microservices that produce and consume \n[AMQP](https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol) messages.\n\nAMQP is an open standard wire specification for asynchronous message communication. AMQP is a\nplatform-neutral binary protocol standard - libraries can be written in different programming \nlanguages and run on different environments.\n\nAMQP is made up of exchanges, queues, and bindings. Clients publish a message to an AMQP exchange\nwith a routing key. Queues are bound to an exchange using a routing key. The exchange then \ndistributes the messages to the interested queues.\n\nThis sample app will demonstrate how to use and test 3 different exchange types:\n\n* Direct Exchange – routes messages to a queue by matching a complete routing key.\n* Fanout Exchange – routes messages to all the queues bound to it.\n* Topic Exchange – routes messages to multiple queues by matching a routing key to a pattern.\n\n## Install Rabbit\nThe fastest way to get up and running is to use the [Docker image](https://registry.hub.docker.com/_/rabbitmq/):\n\n```bash\ndocker pull rabbitmq;\ndocker run -d -p 5672:5672 -p 15672:15672 --name my-rabbit rabbitmq:3-management\n```\n\nOnce it's up and running, you can access the management UI using: \n[http://localhost:15672](http://localhost:15672)\n\nThe default login credentials are `guest/guest`\n\nThe alternative is to install it (and Erlang) natively as per the [official guide](https://www.rabbitmq.com/download.html).\n\n## Build Guide\nYou'll need JDK 11 installed on your dev box.\n\nYou can use [Gradle](https://gradle.org/) or [Maven](https://maven.apache.org) to build the app.\n\nBoth [Gradle Wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) and \n[Maven Wrapper](https://github.com/takari/maven-wrapper) are included in the project.\n\n### Gradle\n1. From the project root, run `./gradlew build`\n1. To generate the Javadoc, run `./gradlew javadoc` and look in the `./build/docs/javadoc` folder.\n\n### Maven\n1. From the project root, run `./mvnw clean install`\n1. Take a look at the Javadoc in the `./target/apidocs` folders after the build completes.\n\n### Checkstyle\nThe app uses the [Google Style Guide](https://google.github.io/styleguide/javaguide.html)\nwhich is enforced during both the Gradle and Maven build - see the [build.gradle](./build.gradle) \nand [pom.xml](./pom.xml) files respectively. The Checkstyle report locations are:\n\n* Gradle - `./build/reports/checkstyle/main.html`\n* Maven - `./target/checkstyle-result.xml`\n\n### Code Coverage\nCode coverage is provided by [JaCoCo](https://www.eclemma.org/jacoco/) and is enforced at build time.\nIt's currently set to 80% line coverage. See the build files. The coverage report locations are:\n\n* Gradle - `./build/report/jacoco/test/html/index.html`\n* Maven - `./target/jacoco-report/index.html`\n\n### Code Quality\n[SpotBugs](https://spotbugs.github.io/) is run at build time. Any bugs found will fail the build. \nThe bug report locations are:\n\n* Gradle - `./build/report/jacoco/test/html/index.html`\n* Maven - `./target/spotbugsXml.xml`\n\n### Tests\nUnit tests are run as part of both Gradle and Maven builds.\n\n[JUnit 4](https://junit.org/junit4/) and [Mockito](https://site.mockito.org/) is used to unit test\nthe code.\n\nThe unit test report locations are:\n* Gradle - `build/reports/tests/test/index.html`\n* Maven - `./target/surefire-reports`\n\nThe integration tests require a running instance of Rabbit -\n[Testcontainers](https://www.testcontainers.org/) is used to achieve this. You'll need to stop any\nother instance of Rabbit that you have running, otherwise the tests will fail to due to port clashes.\n\nThe IT tests are located \n[here](./src/integration-test/java/com/gazbert/rabbitsample/it).\n\nThe Spring profile must be set to 'integration-test' in the \n[./config/application.properties](./config/application.properties) file:\n```properties\nspring.profiles.active=integration-test\n```\n \nTo run the IT tests:\n* Gradle - `./gradlew integrationTests`\n* Maven  `./mvnw clean install -Pint`\n\nThe IT report locations are:\n* Gradle - `./build/reports/tests/integrationTests/index.html`\n* Maven - `./target/failsafe-reports`\n \n## Configuration\nThe configuration is held in the [./config/application.properties](./config/application.properties) \nfile.\n\n```properties\n# Connection Factory details.\namqp.connection.hostname=localhost\namqp.connection.port=5672\namqp.connection.username=guest\namqp.connection.password=guest\n        \n# Set to false to stop error messages going back onto head of queue and looping forever!\nspring.rabbitmq.listener.simple.default-requeue-rejected=false\n\n# Uncomment for the appropriate ErrorHandlingApp demo being run.\n# The Rabbit Docker container will need to be restarted after each change to remove the queues.\namqp.configuration.current=simple-dlq\n#amqp.configuration.current=custom-dlx\n#amqp.configuration.current=parking-lot-dlx\n```\n\nIf the `amqp.connection.*` properties are not set, Spring AMQP will use defaults: $hostname, 5672 and\nguest/guest for credentials.\n\nMore details on the `amqp.configuration.*` properties can be found in the \n[_User Guide_](#running-the-error-handling-app) section below.\n\n## User Guide\n\nThere are 5 demos:\n\n1. A simple \"Hello World!\" app.\n1. A publish messages example using Direct, Fanout, and Topic exchanges. \n1. Error Handling using a simple Dead Letter Queue\n   ([DLQ](https://docs.spring.io/autorepo/docs/spring-cloud-stream-binder-rabbit-docs/1.1.1.RELEASE/reference/html/rabbit-dlq-processing.html)).\n1. Error handling using a custom Dead Lead Exchange ([DLX](https://www.rabbitmq.com/dlx.html)).\n1. Error handling using a \n   [Parking Lot Queue](https://docs.spring.io/autorepo/docs/spring-cloud-stream-binder-rabbit-docs/1.1.1.RELEASE/reference/html/rabbit-dlq-processing.html).\n\nYou'll need to restart the Rabbit Docker container after running each demo app in order to remove \nthe queues.\n\n```bash\ndocker container restart CONTAINER_ID\n```\n\nYou can view the exchanges, queues, and messages in the Rabbit UI: \n[http://localhost:15672](http://localhost:15672)\n\n### \"Hello World!\" app\nThe [Hello World!](./src/main/java/com/gazbert/rabbitsample/helloworld/Application.java) app is \nthe most basic example of a Spring Boot app using Spring AMQP - a good place to start.\n\nFrom the the app from the project root folder using:\n\n* Gradle - `./gradlew bootRun`\n* Maven - `./mvnw spring-boot:run`\n   \n### Publish Message app\nThe [Publish Message](./src/main/java/com/gazbert/rabbitsample/publish/PublishMessageApp.java) app\nwill publish a message to a Direct, Fanout, and Topic Exchange. Message consumers will read the \nmessage off the appropriate queue and log its contents.\n\nFrom the project root folder using:\n\n* Gradle - `./gradlew bootRun -PmainClass=com.gazbert.rabbitsample.publish.PublishMessageApp`\n* Maven - `./mvnw spring-boot:run -Dstart-class=com.gazbert.rabbitsample.publish.PublishMessageApp`\n\n### Error Handling app\nThe [Error Handling](./src/main/java/com/gazbert/rabbitsample/errorhandling/ErrorHandlingApp.java) \napp can be run using 3 different configurations:\n\n1. Simple DLQ - a message is published to a Direct exchange. The Consumer reads the message off the\n   queue and then throws a business exception. This exception is then routed to a DLQ where a \n   Consumer reads the failed message and logs it.\n1. Custom DLX - a business exception is thrown as in the previous example and sent to a DLQ. This \n   time, the Consumer attempts to re-send the message 3 times before giving up and discarding it.\n1. Parking Lot - as in the previous example, the failed message is re-sent 3 times, but instead of\n   discarding it, the Consumer places the failed message on the Parking Lot Queue for manual\n   investigation.\n\nYou'll need to update the [./config/application.properties](./config/application.properties) file\nand set the `amqp.configuration.current` property to the example you want to run:\n\n```properties\n# Valid values are: simple-dlq, custom-dlx, parking-lot-dlx\namqp.configuration.current=simple-dlq\n```\n\nRun the app from the project root folder using:\n\n* Gradle - `./gradlew bootRun -PmainClass=com.gazbert.rabbitsample.errorhandling.ErrorHandlingApp`\n* Maven - `./mvnw spring-boot:run -Dstart-class=com.gazbert.rabbitsample.errorhandling.ErrorHandlingApp`\n   \n## Logging\nLogging for the app is provided by [log4j](http://logging.apache.org/log4j). \nThe log file is written to `logs/app.log` using a rolling policy. When a log file size reaches \n100 MB or a new day is started, it is archived and a new log file is created. \n\nThe app will create up to 7 archives on the same day; these are stored in a directory based on the \ncurrent year and month. Only the last 90 archives are kept. Each archive is compressed using gzip.\n\nThe logging level is set at `info`. You can change this default logging configuration in \nthe [`config/log4j2.xml`](./config/log4j2.xml) file.\n\n## Issue \u0026 Change Management\nIssues and new features are managed using the project \n[Issue Tracker](https://github.com/gazbert/spring-boot-rabbit-app/issues) - submit bugs here.\n \nYou are welcome to take on new features or fix bugs! See [here](CONTRIBUTING.md) for how to get involved. \n\n## Credits\nThis sample app is based off the excellent [Spring AMQP tutorials](https://github.com/eugenp/tutorials/tree/master/spring-amqp)\nby [Baeldung](https://www.baeldung.com/author/baeldung/).\n\n## References\n1. The [Spring AMQP](https://docs.spring.io/spring-amqp/reference/html/) documentation.\n1. [Routing Topologies](https://spring.io/blog/2011/04/01/routing-topologies-for-performance-and-scalability-with-rabbitmq/) and best practice.\n1. The official [Spring AMQP Sample](https://github.com/spring-projects/spring-amqp-samples) apps.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgazbert%2Fspring-boot-rabbit-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgazbert%2Fspring-boot-rabbit-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgazbert%2Fspring-boot-rabbit-app/lists"}