{"id":15024551,"url":"https://github.com/societe-generale/rabbitmq-advanced-spring-boot-starter","last_synced_at":"2025-06-15T13:04:36.913Z","repository":{"id":54794440,"uuid":"119702819","full_name":"societe-generale/rabbitmq-advanced-spring-boot-starter","owner":"societe-generale","description":"A generic library for messaging with rabbit mq with extension on spring boot amqp","archived":false,"fork":false,"pushed_at":"2022-08-26T09:04:03.000Z","size":701,"stargazers_count":92,"open_issues_count":0,"forks_count":29,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-12T06:37:54.343Z","etag":null,"topics":["amqp","eventbus","java","message-broker","rabbitmq","spring","spring-boot"],"latest_commit_sha":null,"homepage":"https://societe-generale.github.io/rabbitmq-advanced-spring-boot-starter/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/societe-generale.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-31T15:08:34.000Z","updated_at":"2025-02-07T13:35:59.000Z","dependencies_parsed_at":"2022-08-14T03:10:18.443Z","dependency_job_id":null,"html_url":"https://github.com/societe-generale/rabbitmq-advanced-spring-boot-starter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/societe-generale/rabbitmq-advanced-spring-boot-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/societe-generale%2Frabbitmq-advanced-spring-boot-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/societe-generale%2Frabbitmq-advanced-spring-boot-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/societe-generale%2Frabbitmq-advanced-spring-boot-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/societe-generale%2Frabbitmq-advanced-spring-boot-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/societe-generale","download_url":"https://codeload.github.com/societe-generale/rabbitmq-advanced-spring-boot-starter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/societe-generale%2Frabbitmq-advanced-spring-boot-starter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259981385,"owners_count":22941144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["amqp","eventbus","java","message-broker","rabbitmq","spring","spring-boot"],"created_at":"2024-09-24T20:00:32.176Z","updated_at":"2025-06-15T13:04:36.857Z","avatar_url":"https://github.com/societe-generale.png","language":"Java","funding_links":[],"categories":["进程间通信"],"sub_categories":["Spring Cloud框架"],"readme":"# rabbitmq-advanced   [![Coverage Status](https://coveralls.io/repos/github/societe-generale/rabbitmq-advanced-spring-boot-starter/badge.svg?branch=master)](https://coveralls.io/github/societe-generale/rabbitmq-advanced-spring-boot-starter?branch=master)  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/943e070973d84f669b1e593747d0e1a1)](https://www.codacy.com/app/anandmnair/rabbitmq-advanced-spring-boot-starter?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=societe-generale/rabbitmq-advanced-spring-boot-starter\u0026amp;utm_campaign=Badge_Grade)\n\n\nA generic library for messaging with RabbitMq, an extension of spring boot amqp.\n\nNote : If you are already using Spring Cloud Stream, you probably don't need this starter. However, if you need AMQP specific features that are not available through Spring Cloud because of its abstraction level, then you may be interested in it, as it provides features that are available in Spring Cloud. Give it a try, and let us know what you think !\nIf you see anything that can be improved or simplified, don't hesitate to propose a change !\n\n\n- [Aim](#aim)\n- [Configurations](#configurations)\n  - [Pom Configuration](#pom-configuration)\n  - [Spring RabbitMQ Configuration](#spring-rabbitmq-configuration)\n  - [RabbitMQ Auto Configuration](#rabbitmq-auto-configuration) \n  - [Info Headers Configuration](#info-headers-configuration)\n  - [Default Exchange Configuration](#default-exchange-configuration)\n  - [Default Queue Configuration](#default-queue-configuration)\n  - [Dead Letter Configuration](#dead-letter-configuration)\n  - [ReQueue Configuration](#requeue-configuration)\n  - [Exchange Configuration](#exchange-configuration)\n  - [Queue Configuration](#queue-configuration)\n  - [Binding Configuration](#binding-configuration)\n- [Exception Handling](#exception-handling)\n- [Correlation Id](#correlation-id)\n- [Contributions](#contributions)\n- [License](#license)\n\n## Aim\nThe aim of this project is to provide a generic spring boot starter project for messaging solution with rabbit mq.\nThis helps us to auto configure rabbit mq exchanges and queues along with the binding by simply providing the configurations in yml.\nThis also helps in better exception handling and monitoring at a single place at a framework level.\nHence no more duplicate code added for creating exchange and queue with the binding in various projects\n\n## Configurations\n\nYou can configure rabbit mq server configurations in application.yml under 'spring.rabbitmq' section.\n\nYou can configure the exchange, queue, binding in application.yml under 'rabbitmq.auto-config'.\n\n### Pom Configuration\nPlease add below pom dependency for rabbitmq-advanced-spring-boot-starter\n```xml\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.societegenerale\u003c/groupId\u003e\n        \u003cartifactId\u003erabbitmq-advanced-spring-boot-starter\u003c/artifactId\u003e\n        \u003cversion\u003e2.0.0.RELEASE\u003c/version\u003e\n        \u003c!-- check the latest version --\u003e\n    \u003c/dependency\u003e\n```\n\n### Spring RabbitMQ Configuration\n\nBelow is the sample spring rabbitmq configuration.\n\n```yaml\nspring:\n  rabbitmq:\n    addresses: \u003cserver\u003e\n    username: \u003cusername\u003e\n    password: \u003cpassword\u003e\n    virtual-host: \u003cv-host\u003e\n    ssl:\n      enabled: false\n    listener:\n      simple:\n        default-requeue-rejected: false\n        retry:\n          enabled: true\n        acknowledge-mode: auto\n```\n\n### RabbitMQ Auto Configuration\n\nBelow is the sample rabbitmq auto configuration.\n\n```yaml\nrabbitmq:\n  auto-config:\n    #enable or disable auto configuration. Default is true\n    enabled: true\n    \n    #Info Headers can be used to add additional information to be added in each message headers\n    info-headers:\n      source-application: ${spring.application.name}\n      \n    #Exchange configuration at default level, will be applied to all the missing configuration of each Exchange.  This can be overridden by configuring at each exchange level.  \n    default-exchange:\n      type: topic\n      durable: false\n      auto-delete: true\n    \n    #Queue configuration at default level, will be applied to all the missing configuration of each Queue.  This can be overridden by configuring at each queue level.\n    default-queue:\n      durable: false\n      auto-delete: true\n      dead-letter-enabled: true\n    \n    #Dead Letter Configuration to configure dead letter exchange and queue postfix.\n    dead-letter-config:\n      dead-letter-exchange:\n        name: my-app-dead-letter-exchange-${user.name}\n        auto-delete: true\n        durable: false\n      queue-postfix: .dlq\n    \n    #Re Queue Configuration to configure the requeue exchange and queue.\n    re-queue-config:\n      enabled: true\n      exchange:\n        name: re-queue-exchange-${user.name}\n      queue:\n        name: re-queue-queue-${user.name}\n      routing-key: requeue.key\n          \n    #You can configure all your exchanges here  \n    exchanges:\n      exchange-one:\n        name: exchange-one-${user.name}\n      exchange-two:\n        name: exchange-two-${user.name}\n      exchange-mock:\n        name: exchange-mock-${user.name}\n    \n    #You can configure all your queue here\n    queues:\n      queue-one:\n        name: queue-one-${user.name}\n      queue-two:\n        name: queue-two-${user.name}\n      queue-mock:\n        name: queue-mock-${user.name}\n        dead-letter-enabled: false\n    \n    #You can configure your bindings for the exchanges and queues here    \n    bindings:\n      binding-one:\n        exchange: exchange-one\n        queue: queue-one\n        routing-key: rkey-one\n      binding-two:\n        exchange: exchange-two\n        queue: queue-two\n        routing-key: rkey-two\n      binding-mock:\n        exchange: exchange-mock\n        queue: queue-mock\n        routing-key: rkey-mock\n```\n\n\n### Info Headers Configuration\n\nYou can configure the info headers here. All these header infos will be added to the each message sent by the system.\n\n```yaml\nrabbitmq:\n  auto-config:\n  . . .\n    #Info Headers can be used to add additional information to be added in each message headers\n    info-headers:\n      source-application: my-demo-application\n      department: company/my-department\n  . . .      \n```\n\n![MessageWithInfoHeader](./doc/image/message-with-info-header.png)\n\n### Default Exchange Configuration\n\nYou can configure the default exchange under this section. All the common properties can be con configured here.\nAt each exchange level you can override the default configuration. All the missing properties will be mapped with default configurations \n\n```yaml\nrabbitmq:\n  auto-config:   \n  . . .     \n    #Exchange configuration at default level, will be applied to all the missing configuration of each Exchange.  This can be overridden by configuring at each exchange level.  \n    default-exchange:\n      type: topic\n      durable: false\n      auto-delete: true\n  . . .      \n```\n\n  1. **type**         : `This indicate the type of the exchange.`\n\n      `The available parsers are : `\n      1. **topic**   : `This is for 'topic exchange' and this is the default type.`\n      2. **direct**  : `This is for 'direct exchange'.`\n      3. **fanout**  : `This is for 'fanout exchange'.`\n      4. **headers** : `This is for 'headers exchange'.`\n\n\n  2. **durable**      : `This indicate the  exchange is durable or not (Boolean)`\n\n  3. **auto-delete**  : `This indicate the  exchange auto-delete enable or not (Boolean)`\n\n  4. **delayed**      : `This indicate the  exchange delayed enable or not (Boolean)`\n\n  5. **internal**     : `This indicate the  exchange internal enable or not (Boolean)`\n\n  6. **arguments**    : `This indicate the  exchange arguments to be added (Map)`\n\n\n### Default Queue Configuration\n\nYou can configure the default queue under this section. All the common properties can be con configured here.\nAt each queue level you can override the default configuration. All the missing properties will be mapped with default configurations\n\n```yaml\nrabbitmq:\n  auto-config:   \n  . . .         \n    #Queue configuration at default level, will be applied to all the missing configuration of each Queue.  This can be overridden by configuring at each queue level.\n    default-queue:\n      durable: false\n      auto-delete: true\n      dead-letter-enabled: true\n  . . .            \n```\n\n  1. **durable**              : `This indicate the  queue is durable or not (Boolean)`\n\n  2. **auto-delete**          : `This indicate the  queue auto-delete enable or not (Boolean)`\n\n  3. **dead-letter-enabled**  : `This indicate whether dead-letter-queue need to auto configure or not (Boolean)`\n\n  4. **exclusive**            : `This indicate the  queue exclusive enable or not (Boolean)`\n\n  5. **arguments**            : `This indicate the  queue arguments to be added (Map)`\n\n\n### Dead Letter Configuration\n\n\nYou can configure the dead letter exchange and queue postfix. Then all you have to do is for queue , enable the dead letter queue.\nThe dead letter queue will be created with the same name as original queue with dead letter queue postfix.\nQueue : my-process-queue\nDead Letter Queue : my-process-queue.dlq\n\n```yaml\nrabbitmq:\n  auto-config:   \n  . . .         \n    #Dead Letter Configuration to configure dead letter exchange and queue postfix.\n    dead-letter-config:\n      dead-letter-exchange:\n        name: my-app-dead-letter-exchange-amqp-test-${user.name}\n        auto-delete: true\n        durable: false\n      queue-postfix: .dlq\n  . . .               \n```\n\n```yaml\nrabbitmq:\n  auto-config:\n  . . .      \n    queues:\n      queue-one:\n        name: queue-one\n        dead-letter-enabled: false\n  . . .              \n```\n\n  1. **type**        : `This indicate the type of the dead letter exchange.`\n\n      ![Exchange Types](./doc/image/exchange-types.png)\n\n      `The available parsers are : `\n      1. **topic**   : `This is for 'topic exchange' and this is the default type.`\n      2. **direct**  : `This is for 'direct exchange'.`\n      3. **fanout**  : `This is for 'fanout exchange'.`\n      4. **headers** : `This is for 'headers exchange'.`\n\n\n  2. **name**        : `This indicate the 'Name' of the dead letter exchange.`\n\n  3. **durable**     : `This indicate the dead letter exchange is durable or not (Boolean)`\n\n  4. **auto-delete** : `This indicate the dead letter exchange auto-delete enable or not (Boolean)`\n\n  5. **delayed**     : `This indicate the dead letter exchange delayed enable or not (Boolean)`\n\n  6. **internal**    : `This indicate the dead letter exchange internal enable or not (Boolean)`\n\n  7. **arguments**   : `This indicate the dead letter exchange arguments to be added (Map)`\n\n\n### ReQueue Configuration\n\nYou can configure the requeue exchange and queue here.\nTo requeue some message from any dead letter queue, you just have to push a requeue message to requeue exchange with requeue routing key.\n\n```yaml\nrabbitmq:\n  auto-config:   \n  . . .         \n    #Re Queue Configuration to configure the requeue exchange and queue.\n    re-queue-config:\n      enabled: true\n      exchange:\n        name: re-queue-exchange-${user.name}\n      queue:\n        name: re-queue-queue-${user.name}\n      routing-key: requeue.key\n  . . .               \n```\n\n  1. **enabled**      : `This is to enable or disable requeue`\n\n  2. **exchange**     : `This indicate the 'exchange' configuration for requeue`\n\n  3. **queue**        : `This indicate the 'queue' configuration for requeue`\n\n  4. **routing-key**  : `This indicate the 'routing-key' configuration for requeue`\n\nBelow is the format for requeue message which requeue 3 message from 'some-queue.dlq' to 'some-queue'\n\n```json\n{\n  \"deadLetterQueue\" : \"some-queue.dlq\",\n  \"messageCount\" : 3\n}\n```\n\n### Exchange Configuration\n\nYou can configure all the exchanges under this section. (Map)\n\n```yaml\nrabbitmq:\n  auto-config:   \n  . . .         \n    #You can configure all your exchanges here  \n    exchanges:\n      exchange-one:\n        name: exchange-one-${user.name}\n      exchange-two:\n        name: exchange-two-${user.name}\n      exchange-mock:\n        name: exchange-mock-${user.name}\n  . . .                 \n```\n\n  1. **type**        : `This indicate the type of the exchange.`\n\n      ![Exchange Types](./doc/image/exchange-types.png)\n\n      `The available parsers are : `\n      1. **topic**   : `This is for 'topic exchange' and this is the default type.`\n      2. **direct**  : `This is for 'direct exchange'.`\n      3. **fanout**  : `This is for 'fanout exchange'.`\n      4. **headers** : `This is for 'headers exchange'.`\n\n\n  2. **name**        : `This indicate the 'Name' of the exchange.`\n\n  3. **durable**     : `This indicate the  exchange is durable or not (Boolean)`\n\n  4. **auto-delete** : `This indicate the  exchange auto-delete enable or not (Boolean)`\n\n  5. **delayed**     : `This indicate the  exchange delayed enable or not (Boolean)`\n\n  6. **internal**    : `This indicate the  exchange internal enable or not (Boolean)`\n\n  7. **arguments**   : `This indicate the  exchange arguments to be added (Map)`\n\n\n### Queue Configuration\n\nYou can configure all the queues under this section. (Map)\n\n```yaml\nrabbitmq:\n  auto-config:   \n  . . .         \n    #You can configure all your queue here\n    queues:\n      queue-one:\n        name: queue-one-${user.name}\n      queue-two:\n        name: queue-two-${user.name}\n      queue-mock:\n        name: queue-mock-${user.name}\n        dead-letter-enabled: false\n  . . .                 \n```\n  1. **name**  : `This indicate the 'Name' of the queue.`\n\n  2. **durable**  : `This indicate the  queue is durable or not (Boolean)`\n\n  3. **auto-delete**  : `This indicate the  queue auto-delete enable or not (Boolean)`\n\n  4. **dead-letter-enabled**  : `This indicate whether dead-letter-queue need to auto configure or not (Boolean)`\n\n  5. **exclusive**  : `This indicate the  queue exclusive enable or not (Boolean)`\n\n  6. **arguments**  : `This indicate the  queue arguments to be added (Map)`\n\n\n### Binding Configuration\n\nYou can configure all the bindings under this section. (Map)\n\n```yaml\nrabbitmq:\n  auto-config:   \n  . . .         \n    #You can configure your bindings for the exchanges and queues here    \n    bindings:\n      binding-one:\n        exchange: exchange-one\n        queue: queue-one\n        routing-key: rkey-one\n      binding-two:\n        exchange: exchange-two\n        queue: queue-two\n        routing-key: rkey-two\n      binding-mock:\n        exchange: exchange-mock\n        queue: queue-mock\n        routing-key: rkey-mock\n  . . .                 \n```\n\n  1. **exchange**    : `This indicate the exchange key which you want to bind with the given queue.`\n\n  2. **queue**       : `This indicate the queue key which you want to bind with the given exchange.`\n\n  3. **routing-key** : `This indicate the routing-key used to bind the given exchange and queue`\n\n  4. **arguments**   : `This indicate the arguments to be added for the binding (Map)`\n\n\n### Exception Handling\n\n#### Enable Dead Letter Queue\n\nYou can enable dead letter queue for each queue by providing below configuration in respective queue configuration or at the default queue configuration\n\n```yaml\nrabbitmq: \n  auto-config:\n   \n   . . .\n      \n    #Dead Letter Configuration to configure dead letter exchange and queue postfix.\n    dead-letter-config:\n      dead-letter-exchange:\n        name: my-app-dead-letter-exchange-amqp-test-${user.name}\n        auto-delete: true\n        durable: false\n      queue-postfix: .dlq\n  \n  . . .  \n        \n    queues:\n      some-queue: \n        ...\n        dead-letter-enabled: true  #Enable Dead Letter Queue at individual queue level\n        ...\n\n  . . .  \n```\nWith the above configuration , the failed message will be sent to the dead letter queue which is bind to the dead letter exchange as per the configuration. \nExample : If the queue name is **'some.dummy.queue'** and dead-letter-queue-postfix is **'.dlq'** then dead letter queue will be **'some.dummy.queue.dlq'**\n\n![DeadLetterMessage](./doc/image/dead-letter-message.png)\n\nThe above is the sample message in the dead letter queue. \n\n#### Message Exception Handler\n\nIn addition to the above dead letter queue, we can also configure MessageExceptionHandler to have additional exception handling like saving the failed message exception to database, or doing additional logging etc.  \nIf you want to handle MessageException, you can implement the MessageExceptionHandler and configure the bean in Spring.\nEach message and the exception will be passed to all MessageExceptionHandler (if its configured)\n\nYou need to enable the retry to use the message exception handler\n```yaml\nspring:\n  rabbitmq:\n  ...\n  ...\n    listener:\n      default-requeue-rejected: false\n      retry:\n        enabled: true\n```\n\n![ExceptionHandler](./doc/image/exception-handling-arch.png)\n\n```java\n    public interface MessageExceptionHandler {\n      void handle(Message message, Throwable cause);\n    } \n```\n\n```java\n    @Slf4j\n    public class LogMessageExceptionHandler implements MessageExceptionHandler {\n    \n        @Override\n        public void handle(Message message, Throwable cause) {\n              Map\u003cString, Object\u003e headers = message.getMessageProperties().getHeaders();\n              log.warn(\"Dead letter message from queue {{}} , message {{}} , headers {{}} :  cause\",\n              headers.get(\"x-original-queue\"), getMessageString(message), headers, cause);\n        }\n        \n        protected String getMessageString(Message message) {\n            String contentType = message.getMessageProperties() != null?message.getMessageProperties().getContentType():null;\n            if(\"text/plain\".equals(contentType) || \"application/json\".equals(contentType) || \"text/x-json\".equals(contentType) || \"application/xml\".equals(contentType)) {\n                return new String(message.getBody());\n            }\n            else {\n                return Arrays.toString(message.getBody()) + \"(byte[\" + message.getBody().length + \"])\";\n            }\n        }\n    }\n```\n \n```java\n\n    @Configuration\n    public class ConfigClass {\n  \n        //...\n  \n        @Bean\n        @Order(1)\n        public MessageExceptionHandler logMessageExceptionHandler() {\n            return new LogMessageExceptionHandler();\n        }\n\n       //...\n       \n    }\n```\n\n### Correlation Id\nThe correlation id will be added to the message automatically as part of tracer. \n  \n![Tracer Correlation Id Message](./doc/image/tracer-correlation-id-message.png)\n\n![Tracer Correlation Id log](./doc/image/tracer-log.png)\n\n### Contributions\n\nMain author of the project is [Anand Manissery](https://github.com/anandmnair). For any question or suggestion please initiate a discussion through the [project issues](https://github.com/societe-generale/rabbitmq-advanced-spring-boot-starter/issues).\n\n[Contrubutors](https://github.com/societe-generale/rabbitmq-advanced-spring-boot-starter/graphs/contributors)\n\nPull requests are welcome. We follow a strict test driven approach, so make sure your contribution is well tested.  \n\n### Thanks and acknowledgement\n \n- [Vincent FUCHS](https://github.com/vincent-fuchs) \n- Patrice FRICARD\n- Igor LOVICH\n- Rahul DAS\n\nThanks a lot for your inputs and feedback that have made the v1.0.0 possible !\n\n### License\nLicense is under the Apache V2 License.  \nSee [LICENSE.md](LICENSE.md) or [Apache License](http://www.apache.org/licenses/LICENSE-2.0) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsociete-generale%2Frabbitmq-advanced-spring-boot-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsociete-generale%2Frabbitmq-advanced-spring-boot-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsociete-generale%2Frabbitmq-advanced-spring-boot-starter/lists"}