Skip to content

Commit 01e6365

Browse files
committed
GH-1307: Doc Polishing
Resolves #1307 Define beans with narrower types.
1 parent 67e5870 commit 01e6365

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

src/reference/asciidoc/amqp.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ You can declare it as a `@Bean` and inject it into the connection factory, as th
410410
[source, java]
411411
----
412412
@Bean
413-
public ConnectionNameStrategy cns() {
413+
public SimplePropertyValueConnectionNameStrategy cns() {
414414
return new SimplePropertyValueConnectionNameStrategy("spring.application.name");
415415
}
416416
@@ -664,7 +664,7 @@ The following example configuration shows how to configure the factories:
664664
private ConfigurationProperties props;
665665
666666
@Bean
667-
public ConnectionFactory defaultConnectionFactory() {
667+
public CachingConnectionFactory defaultConnectionFactory() {
668668
CachingConnectionFactory cf = new CachingConnectionFactory();
669669
cf.setAddresses(this.props.getAddresses());
670670
cf.setUsername(this.props.getUsername());
@@ -674,7 +674,7 @@ public ConnectionFactory defaultConnectionFactory() {
674674
}
675675
676676
@Bean
677-
public ConnectionFactory queueAffinityCF(
677+
public LocalizedQueueConnectionFactory queueAffinityCF(
678678
@Qualifier("defaultConnectionFactory") ConnectionFactory defaultCF) {
679679
return new LocalizedQueueConnectionFactory(defaultCF,
680680
StringUtils.commaDelimitedListToStringArray(this.props.getAddresses()),
@@ -956,7 +956,7 @@ The following example uses the `@Configuration` annotation in Java:
956956
[source,java]
957957
----
958958
@Bean
959-
public AmqpTemplate rabbitTemplate() {
959+
public RabbitTemplate rabbitTemplate() {
960960
RabbitTemplate template = new RabbitTemplate(connectionFactory());
961961
RetryTemplate retryTemplate = new RetryTemplate();
962962
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
@@ -1855,7 +1855,7 @@ public class ExampleAmqpConfiguration {
18551855
}
18561856
18571857
@Bean
1858-
public ConnectionFactory rabbitConnectionFactory() {
1858+
public CachingConnectionFactory rabbitConnectionFactory() {
18591859
CachingConnectionFactory connectionFactory =
18601860
new CachingConnectionFactory("localhost");
18611861
connectionFactory.setUsername("guest");
@@ -2415,7 +2415,7 @@ public class AppConfig implements RabbitListenerConfigurer {
24152415
}
24162416
24172417
@Bean
2418-
public ConversionService myConversionService() {
2418+
public DefaultConversionService myConversionService() {
24192419
DefaultConversionService conv = new DefaultConversionService();
24202420
conv.addConverter(mySpecialConverter());
24212421
return conv;
@@ -4490,7 +4490,7 @@ The following listing shows the code for `AbstractStockRabbitConfiguration`:
44904490
public abstract class AbstractStockAppRabbitConfiguration {
44914491
44924492
@Bean
4493-
public ConnectionFactory connectionFactory() {
4493+
public CachingConnectionFactory connectionFactory() {
44944494
CachingConnectionFactory connectionFactory =
44954495
new CachingConnectionFactory("localhost");
44964496
connectionFactory.setUsername("guest");
@@ -4507,7 +4507,7 @@ public abstract class AbstractStockAppRabbitConfiguration {
45074507
}
45084508
45094509
@Bean
4510-
public MessageConverter jsonMessageConverter() {
4510+
public Jackson2JsonMessageConverter jsonMessageConverter() {
45114511
return new Jackson2JsonMessageConverter();
45124512
}
45134513
@@ -4663,7 +4663,7 @@ The following example shows how to do so:
46634663
public static class Config {
46644664
46654665
@Bean
4666-
public ConnectionFactory cf() {
4666+
public CachingConnectionFactory cf() {
46674667
return new CachingConnectionFactory("localhost");
46684668
}
46694669

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
@@ -472,20 +472,15 @@ IMPORTANT: The method must be called before invoking any of the `isRunning()` st
472472
Variable values are applied to all instances created after this invocation.
473473
Invoke `clearEnvironmentVariableOverrides()` to reset the rule to use defaults (including any actual environment variables).
474474

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

478478
====
479479
[source, java]
480480
----
481481
@Bean
482-
public ConnectionFactory rabbitConnectionFactory() {
483-
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
484-
connectionFactory.setHost(brokerRunning.getHostName());
485-
connectionFactory.setPort(brokerRunning.getPort());
486-
connectionFactory.setUsername(brokerRunning.getUser());
487-
connectionFactory.setPassword(brokerRunning.getPassword());
488-
return connectionFactory;
482+
public CachingConnectionFactory rabbitConnectionFactory() {
483+
return new CachingConnectionFactory(brokerRunning.getConnectionFactory());
489484
}
490485
----
491486
====

0 commit comments

Comments
 (0)