Skip to content

Commit 469e7f5

Browse files
authored
GH-2472: Doc SSL with Java or Boot
Resolves #2472
1 parent 0cfe2f9 commit 469e7f5

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/reference/asciidoc/amqp.adoc

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,40 @@ Previously, you had to configure the SSL options programmatically.
545545
The following example shows how to configure a `RabbitConnectionFactoryBean`:
546546

547547
====
548-
[source,xml]
548+
[source,java,role=primary]
549+
.Java
550+
----
551+
@Bean
552+
RabbitConnectionFactoryBean rabbitConnectionFactory() {
553+
RabbitConnectionFactoryBean factoryBean = new RabbitConnectionFactoryBean();
554+
factoryBean.setUseSSL(true);
555+
factoryBean.setSslPropertiesLocation(new ClassPathResource("secrets/rabbitSSL.properties"));
556+
return factoryBean;
557+
}
558+
559+
@Bean
560+
CachingConnectionFactory connectionFactory(ConnectionFactory rabbitConnectionFactory) {
561+
CachingConnectionFactory ccf = new CachingConnectionFactory(rabbitConnectionFactory);
562+
ccf.setHost("...");
563+
// ...
564+
return ccf;
565+
}
566+
----
567+
[source,properties,role=secondary]
568+
.Boot application.properties
569+
----
570+
spring.rabbitmq.ssl.enabled:true
571+
spring.rabbitmq.ssl.keyStore=...
572+
spring.rabbitmq.ssl.keyStoreType=jks
573+
spring.rabbitmq.ssl.keyStorePassword=...
574+
spring.rabbitmq.ssl.trustStore=...
575+
spring.rabbitmq.ssl.trustStoreType=jks
576+
spring.rabbitmq.ssl.trustStorePassword=...
577+
spring.rabbitmq.host=...
578+
...
579+
----
580+
[source,xml,role=secondary]
581+
.XML
549582
----
550583
<rabbit:connection-factory id="rabbitConnectionFactory"
551584
connection-factory="clientConnectionFactory"
@@ -557,7 +590,7 @@ The following example shows how to configure a `RabbitConnectionFactoryBean`:
557590
<bean id="clientConnectionFactory"
558591
class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean">
559592
<property name="useSSL" value="true" />
560-
<property name="sslPropertiesLocation" value="file:/secrets/rabbitSSL.properties"/>
593+
<property name="sslPropertiesLocation" value="classpath:secrets/rabbitSSL.properties"/>
561594
</bean>
562595
----
563596
====

0 commit comments

Comments
 (0)