From 40025c8ecca46b43dbe657132725fbe6fa24a908 Mon Sep 17 00:00:00 2001 From: Tran Ngoc Nhan Date: Wed, 28 May 2025 13:42:51 +0700 Subject: [PATCH] Improve connections document Signed-off-by: Tran Ngoc Nhan --- src/reference/antora/antora-playbook.yml | 1 + .../modules/ROOT/pages/amqp/connections.adoc | 61 +++++++++++-------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/reference/antora/antora-playbook.yml b/src/reference/antora/antora-playbook.yml index 1b86b09228..8ce0ba403a 100644 --- a/src/reference/antora/antora-playbook.yml +++ b/src/reference/antora/antora-playbook.yml @@ -24,6 +24,7 @@ asciidoc: - '@asciidoctor/tabs' - '@springio/asciidoctor-extensions' - '@springio/asciidoctor-extensions/javadoc-extension' + - '@springio/asciidoctor-extensions/configuration-properties-extension' sourcemap: true urls: latest_version_segment: '' diff --git a/src/reference/antora/modules/ROOT/pages/amqp/connections.adoc b/src/reference/antora/modules/ROOT/pages/amqp/connections.adoc index f85b670af9..8d8969e3cc 100644 --- a/src/reference/antora/modules/ROOT/pages/amqp/connections.adoc +++ b/src/reference/antora/modules/ROOT/pages/amqp/connections.adoc @@ -278,7 +278,7 @@ public ConnectionFactory rabbitConnectionFactory(ConnectionNameStrategy cns) { The property must exist in the application context's `Environment`. NOTE: When using Spring Boot and its autoconfigured connection factory, you need only declare the `ConnectionNameStrategy` `@Bean`. -Boot auto-detects the bean and wires it into the factory. +Spring Boot auto-detects the bean and wires it into the factory. [[blocked-connections-and-resource-constraints]] == Blocked Connections and Resource Constraints @@ -332,8 +332,11 @@ Other setters delegate to the underlying factory. Previously, you had to configure the SSL options programmatically. The following example shows how to configure a `RabbitConnectionFactoryBean`: +[tabs] +====== +Java:: ++ [source,java,role=primary] -.Java ---- @Bean RabbitConnectionFactoryBean rabbitConnectionFactory() { @@ -351,34 +354,40 @@ CachingConnectionFactory connectionFactory(ConnectionFactory rabbitConnectionFac return ccf; } ---- -[source,properties,role=secondary] -.Boot application.properties ----- -spring.rabbitmq.ssl.enabled:true -spring.rabbitmq.ssl.keyStore=... -spring.rabbitmq.ssl.keyStoreType=jks -spring.rabbitmq.ssl.keyStorePassword=... -spring.rabbitmq.ssl.trustStore=... -spring.rabbitmq.ssl.trustStoreType=jks -spring.rabbitmq.ssl.trustStorePassword=... -spring.rabbitmq.host=... -... ----- +XML:: ++ [source,xml,role=secondary] -.XML ---- - + + + + + +---- +====== - - - - +Spring Boot application file (`.yaml` or `.properties`) + +[configprops%novalidate,yaml] +---- +spring: + rabbitmq: + host: ... + ssl: + keyStoreType: jks + trustStoreType: jks + keyStore: ... + trustStore: ... + trustStorePassword: ... + keyStorePassword: ... + enabled: true ---- See the https://www.rabbitmq.com/ssl.html[RabbitMQ Documentation] for information about configuring SSL. @@ -622,7 +631,7 @@ To add `WebFlux` to the class path: compile 'org.springframework.amqp:spring-rabbit' ---- -You can also use other REST technology by implementing `LocalizedQueueConnectionFactory.NodeLocator` and overriding its `createClient, ``restCall`, and optionally, `close` methods. +You can also use other REST technology by implementing javadoc:org.springframework.amqp.rabbit.connection.LocalizedQueueConnectionFactory#setNodeLocator(org.springframework.amqp.rabbit.connection.NodeLocator)[LocalizedQueueConnectionFactory#setNodeLocator] and overriding its `createClient`, `restCall`, and optionally, `close` methods. [source, java] ---- @@ -634,9 +643,9 @@ lqcf.setNodeLocator(new NodeLocator() { } @Override - public HashMap restCall(MyClient client, URI uri) { + public Map restCall(MyClient client, String baseUri, String vhost, String queue) throws URISyntaxException { ... - }); + } }); ----