Skip to content

Commit f690ab7

Browse files
Improve connections document
* Add `springio/asciidoctor-extensions/configuration-properties-extension` to draw YAML properly in docs * Refactor `connections.adoc` for proper `NodeLocator` API * Show tabs for `ConnectionFactory` sample * Tabs for Spring Boot properties sample Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent 73fbccb commit f690ab7

File tree

2 files changed

+36
-26
lines changed

2 files changed

+36
-26
lines changed

src/reference/antora/antora-playbook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ asciidoc:
2424
- '@asciidoctor/tabs'
2525
- '@springio/asciidoctor-extensions'
2626
- '@springio/asciidoctor-extensions/javadoc-extension'
27+
- '@springio/asciidoctor-extensions/configuration-properties-extension'
2728
sourcemap: true
2829
urls:
2930
latest_version_segment: ''

src/reference/antora/modules/ROOT/pages/amqp/connections.adoc

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public ConnectionFactory rabbitConnectionFactory(ConnectionNameStrategy cns) {
278278
The property must exist in the application context's `Environment`.
279279

280280
NOTE: When using Spring Boot and its autoconfigured connection factory, you need only declare the `ConnectionNameStrategy` `@Bean`.
281-
Boot auto-detects the bean and wires it into the factory.
281+
Spring Boot auto-detects the bean and wires it into the factory.
282282

283283
[[blocked-connections-and-resource-constraints]]
284284
== Blocked Connections and Resource Constraints
@@ -332,8 +332,11 @@ Other setters delegate to the underlying factory.
332332
Previously, you had to configure the SSL options programmatically.
333333
The following example shows how to configure a `RabbitConnectionFactoryBean`:
334334

335+
[tabs]
336+
======
337+
Java::
338+
+
335339
[source,java,role=primary]
336-
.Java
337340
----
338341
@Bean
339342
RabbitConnectionFactoryBean rabbitConnectionFactory() {
@@ -351,34 +354,40 @@ CachingConnectionFactory connectionFactory(ConnectionFactory rabbitConnectionFac
351354
return ccf;
352355
}
353356
----
354-
[source,properties,role=secondary]
355-
.Boot application.properties
356-
----
357-
spring.rabbitmq.ssl.enabled:true
358-
spring.rabbitmq.ssl.keyStore=...
359-
spring.rabbitmq.ssl.keyStoreType=jks
360-
spring.rabbitmq.ssl.keyStorePassword=...
361-
spring.rabbitmq.ssl.trustStore=...
362-
spring.rabbitmq.ssl.trustStoreType=jks
363-
spring.rabbitmq.ssl.trustStorePassword=...
364-
spring.rabbitmq.host=...
365-
...
366-
----
357+
XML::
358+
+
367359
[source,xml,role=secondary]
368-
.XML
369360
----
370-
<rabbit:connection-factory id="rabbitConnectionFactory"
371-
connection-factory="clientConnectionFactory"
361+
<bean id="rabbitConnectionFactory"
362+
class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean">
363+
<property name="useSSL" value="true" />
364+
<property name="sslPropertiesLocation" value="classpath:secrets/rabbitSSL.properties"/>
365+
</bean>
366+
367+
<rabbit:connection-factory id="connectionFactory"
368+
connection-factory="rabbitConnectionFactory"
372369
host="${host}"
373370
port="${port}"
374371
virtual-host="${vhost}"
375372
username="${username}" password="${password}" />
373+
----
374+
======
376375

377-
<bean id="clientConnectionFactory"
378-
class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean">
379-
<property name="useSSL" value="true" />
380-
<property name="sslPropertiesLocation" value="classpath:secrets/rabbitSSL.properties"/>
381-
</bean>
376+
Spring Boot application file (`.yaml` or `.properties`)
377+
378+
[configprops%novalidate,yaml]
379+
----
380+
spring:
381+
rabbitmq:
382+
host: ...
383+
ssl:
384+
keyStoreType: jks
385+
trustStoreType: jks
386+
keyStore: ...
387+
trustStore: ...
388+
trustStorePassword: ...
389+
keyStorePassword: ...
390+
enabled: true
382391
----
383392

384393
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:
622631
compile 'org.springframework.amqp:spring-rabbit'
623632
----
624633

625-
You can also use other REST technology by implementing `LocalizedQueueConnectionFactory.NodeLocator` and overriding its `createClient, ``restCall`, and optionally, `close` methods.
634+
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.
626635

627636
[source, java]
628637
----
@@ -634,9 +643,9 @@ lqcf.setNodeLocator(new NodeLocator<MyClient>() {
634643
}
635644
636645
@Override
637-
public HashMap<String, Object> restCall(MyClient client, URI uri) {
646+
public Map<String, Object> restCall(MyClient client, String baseUri, String vhost, String queue) throws URISyntaxException {
638647
...
639-
});
648+
}
640649
641650
});
642651
----

0 commit comments

Comments
 (0)