-
Notifications
You must be signed in to change notification settings - Fork 27
Autoconfiguration
Today if we want to create a custom communication (like one using ssl for example) with RabbitMQ using Spring AMQP, we need to create a couple of beans like ConnectionFactory, RabbitAdmin, RabbitTemplate, AbstractRabbitListenerContainerFactory. And if you have more than 1 virtual host in your RabbitMQ, you need to create this ecosystem for each virtual host and management the RabbitTemplate and RabbitListener.
All these configurations take a long time to work well and could be a headache.
Thinking in this problem, this library auto-configure all these beans and make the management for you.
The only thing that you need to do is define the configuration in your application.properties / yaml and the magic happens!
Example:
spring.rabbitmq.custom.shared.host=localhost
spring.rabbitmq.custom.shared.port=5672
spring.rabbitmq.custom.shared.ttlRetryMessage=5000
spring.rabbitmq.custom.shared.maxRetriesAttempts=5
spring.rabbitmq.custom.shared.autoCreate=true
spring.rabbitmq.custom.some-event.ttlMultiply=2
spring.rabbitmq.custom.some-event.queueRoutingKey=ROUTING.KEY.TEST
spring.rabbitmq.custom.some-event.exchange=ex.custom.direct
spring.rabbitmq.custom.some-event.exchangeType=direct
spring.rabbitmq.custom.some-event.queue=queue.custom.test
spring.rabbitmq.custom.some-event.concurrentConsumers=1
spring.rabbitmq.custom.some-event.maxConcurrentConsumers=1
spring.rabbitmq.custom.some-event.virtualHost=tradeshift
spring.rabbitmq.custom.some-event.primary=true
spring.rabbitmq.custom.some-event.sslConnection=true
spring.rabbitmq.custom.some-event.tlsKeystoreLocation=file:///etc/tradeshift/your-service/tls-keystore.pkcs12
spring.rabbitmq.custom.some-event.tlsKeystorePassword=${RABBITMQ_PASS_CERT}
spring.rabbitmq.custom.another-event.queueRoutingKey=TEST.QUEUE
spring.rabbitmq.custom.another-event.exchange=ex_test_1
spring.rabbitmq.custom.another-event.exchangeType=direct
spring.rabbitmq.custom.another-event.queue=queue_test_1
spring.rabbitmq.custom.another-event.concurrentConsumers=1
spring.rabbitmq.custom.another-event.maxConcurrentConsumers=1
spring.rabbitmq.custom.another-event.username=guest
spring.rabbitmq.custom.another-event.password=${RABBITMQ_PASS}
You can disable the autoconfiguration, to do this, use the properties below:
Property | Value | Definition |
---|---|---|
spring.rabbitmq.enable.custom.autoconfiguration | false | With this option you can disable the autoconfiguration and use your own configuration with other benefits of this lib |
spring.rabbitmq.custom.<YOUR_EVENT>.rabbitTemplateBeanName | If you have more than 1 connection and you want to disable the autoconfiguration you need to inform the name of the RabbitTemplate bean for each connection |
Example:
spring.rabbitmq.enable.custom.autoconfiguration=false
spring.rabbitmq.custom.some-event.ttlRetryMessage=5000
spring.rabbitmq.custom.some-event.maxRetriesAttempts=3
spring.rabbitmq.custom.some-event.ttlMultiply=2
spring.rabbitmq.custom.some-event.queueRoutingKey=ROUTING.KEY.TEST
spring.rabbitmq.custom.some-event.exchange=ex.custom.direct
spring.rabbitmq.custom.some-event.queue=queue.custom.test
spring.rabbitmq.custom.some-event.virtualHost=tradeshift
spring.rabbitmq.custom.some-event.rabbitTemplateBeanName=rabbitTemplateForTradeshiftVH
spring.rabbitmq.custom.another-event.ttlRetryMessage=5000
spring.rabbitmq.custom.another-event.maxRetriesAttempts=5
spring.rabbitmq.custom.another-event.queueRoutingKey=TEST.QUEUE
spring.rabbitmq.custom.another-event.exchange=ex_test_1
spring.rabbitmq.custom.another-event.queue=queue_test_1
spring.rabbitmq.custom.another-event.rabbitTemplateBeanName=rabbitTemplateForDefaultVH