Skip to content

Commit 2c91196

Browse files
committed
GH-1307: Doc Polishing
Resolves #1307 Define beans with narrower types.
1 parent 35caa12 commit 2c91196

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

src/reference/asciidoc/amqp.adoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ You can declare it as a `@Bean` and inject it into the connection factory, as th
469469
[source, java]
470470
----
471471
@Bean
472-
public ConnectionNameStrategy cns() {
472+
public SimplePropertyValueConnectionNameStrategy cns() {
473473
return new SimplePropertyValueConnectionNameStrategy("spring.application.name");
474474
}
475475
@@ -725,7 +725,7 @@ The following example configuration shows how to configure the factories:
725725
private ConfigurationProperties props;
726726
727727
@Bean
728-
public ConnectionFactory defaultConnectionFactory() {
728+
public CachingConnectionFactory defaultConnectionFactory() {
729729
CachingConnectionFactory cf = new CachingConnectionFactory();
730730
cf.setAddresses(this.props.getAddresses());
731731
cf.setUsername(this.props.getUsername());
@@ -735,7 +735,7 @@ public ConnectionFactory defaultConnectionFactory() {
735735
}
736736
737737
@Bean
738-
public ConnectionFactory queueAffinityCF(
738+
public LocalizedQueueConnectionFactory queueAffinityCF(
739739
@Qualifier("defaultConnectionFactory") ConnectionFactory defaultCF) {
740740
return new LocalizedQueueConnectionFactory(defaultCF,
741741
StringUtils.commaDelimitedListToStringArray(this.props.getAddresses()),
@@ -1017,7 +1017,7 @@ The following example uses the `@Configuration` annotation in Java:
10171017
[source,java]
10181018
----
10191019
@Bean
1020-
public AmqpTemplate rabbitTemplate() {
1020+
public RabbitTemplate rabbitTemplate() {
10211021
RabbitTemplate template = new RabbitTemplate(connectionFactory());
10221022
RetryTemplate retryTemplate = new RetryTemplate();
10231023
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
@@ -1923,7 +1923,7 @@ public class ExampleAmqpConfiguration {
19231923
}
19241924
19251925
@Bean
1926-
public ConnectionFactory rabbitConnectionFactory() {
1926+
public CachingConnectionFactory rabbitConnectionFactory() {
19271927
CachingConnectionFactory connectionFactory =
19281928
new CachingConnectionFactory("localhost");
19291929
connectionFactory.setUsername("guest");
@@ -2458,7 +2458,7 @@ Starting with version 2.3, you can override the factory converter by specifying
24582458
[source, java]
24592459
----
24602460
@Bean
2461-
public MessageConverter jsonConverter() {
2461+
public Jackson2JsonMessageConverter jsonConverter() {
24622462
return new Jackson2JsonMessageConverter();
24632463
}
24642464
@@ -2502,7 +2502,7 @@ public class AppConfig implements RabbitListenerConfigurer {
25022502
}
25032503
25042504
@Bean
2505-
public ConversionService myConversionService() {
2505+
public DefaultConversionService myConversionService() {
25062506
DefaultConversionService conv = new DefaultConversionService();
25072507
conv.addConverter(mySpecialConverter());
25082508
return conv;
@@ -4613,7 +4613,7 @@ The following listing shows the code for `AbstractStockRabbitConfiguration`:
46134613
public abstract class AbstractStockAppRabbitConfiguration {
46144614
46154615
@Bean
4616-
public ConnectionFactory connectionFactory() {
4616+
public CachingConnectionFactory connectionFactory() {
46174617
CachingConnectionFactory connectionFactory =
46184618
new CachingConnectionFactory("localhost");
46194619
connectionFactory.setUsername("guest");
@@ -4630,7 +4630,7 @@ public abstract class AbstractStockAppRabbitConfiguration {
46304630
}
46314631
46324632
@Bean
4633-
public MessageConverter jsonMessageConverter() {
4633+
public Jackson2JsonMessageConverter jsonMessageConverter() {
46344634
return new Jackson2JsonMessageConverter();
46354635
}
46364636
@@ -4786,7 +4786,7 @@ The following example shows how to do so:
47864786
public static class Config {
47874787
47884788
@Bean
4789-
public ConnectionFactory cf() {
4789+
public CachingConnectionFactory cf() {
47904790
return new CachingConnectionFactory("localhost");
47914791
}
47924792

src/reference/asciidoc/quick-tour.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ String foo = (String) template.receiveAndConvert("myqueue");
135135
public class RabbitConfiguration {
136136
137137
@Bean
138-
public ConnectionFactory connectionFactory() {
138+
public CachingConnectionFactory connectionFactory() {
139139
return new CachingConnectionFactory("localhost");
140140
}
141141
142142
@Bean
143-
public AmqpAdmin amqpAdmin() {
143+
public RabbitAdmin amqpAdmin() {
144144
return new RabbitAdmin(connectionFactory());
145145
}
146146

src/reference/asciidoc/sample-apps.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The following listing shows how the connection factory is created:
2828
[source,java]
2929
----
3030
@Bean
31-
public ConnectionFactory connectionFactory() {
31+
public CachingConnectionFactory connectionFactory() {
3232
CachingConnectionFactory connectionFactory =
3333
new CachingConnectionFactory("localhost");
3434
connectionFactory.setUsername("guest");

src/reference/asciidoc/testing.adoc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -522,20 +522,15 @@ IMPORTANT: The method must be called before invoking any of the `isRunning()` st
522522
Variable values are applied to all instances created after this invocation.
523523
Invoke `clearEnvironmentVariableOverrides()` to reset the rule to use defaults (including any actual environment variables).
524524

525-
In your test cases, you can use those properties when creating the connection factory.
525+
In your test cases, you can use the `brokerRunning` when creating the connection factory; `getConnectionFactory()` returns the rule's RabbitMQ `ConnectionFactory`.
526526
The following example shows how to do so:
527527

528528
====
529529
[source, java]
530530
----
531531
@Bean
532-
public ConnectionFactory rabbitConnectionFactory() {
533-
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
534-
connectionFactory.setHost(brokerRunning.getHostName());
535-
connectionFactory.setPort(brokerRunning.getPort());
536-
connectionFactory.setUsername(brokerRunning.getUser());
537-
connectionFactory.setPassword(brokerRunning.getPassword());
538-
return connectionFactory;
532+
public CachingConnectionFactory rabbitConnectionFactory() {
533+
return new CachingConnectionFactory(brokerRunning.getConnectionFactory());
539534
}
540535
----
541536
====

0 commit comments

Comments
 (0)