Skip to content

Commit

Permalink
GH-1307: Doc Polishing
Browse files Browse the repository at this point in the history
Resolves #1307

Define beans with narrower types.
  • Loading branch information
garyrussell committed Feb 11, 2021
1 parent 35caa12 commit 2c91196
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
20 changes: 10 additions & 10 deletions src/reference/asciidoc/amqp.adoc
Expand Up @@ -469,7 +469,7 @@ You can declare it as a `@Bean` and inject it into the connection factory, as th
[source, java]
----
@Bean
public ConnectionNameStrategy cns() {
public SimplePropertyValueConnectionNameStrategy cns() {
return new SimplePropertyValueConnectionNameStrategy("spring.application.name");
}
Expand Down Expand Up @@ -725,7 +725,7 @@ The following example configuration shows how to configure the factories:
private ConfigurationProperties props;
@Bean
public ConnectionFactory defaultConnectionFactory() {
public CachingConnectionFactory defaultConnectionFactory() {
CachingConnectionFactory cf = new CachingConnectionFactory();
cf.setAddresses(this.props.getAddresses());
cf.setUsername(this.props.getUsername());
Expand All @@ -735,7 +735,7 @@ public ConnectionFactory defaultConnectionFactory() {
}
@Bean
public ConnectionFactory queueAffinityCF(
public LocalizedQueueConnectionFactory queueAffinityCF(
@Qualifier("defaultConnectionFactory") ConnectionFactory defaultCF) {
return new LocalizedQueueConnectionFactory(defaultCF,
StringUtils.commaDelimitedListToStringArray(this.props.getAddresses()),
Expand Down Expand Up @@ -1017,7 +1017,7 @@ The following example uses the `@Configuration` annotation in Java:
[source,java]
----
@Bean
public AmqpTemplate rabbitTemplate() {
public RabbitTemplate rabbitTemplate() {
RabbitTemplate template = new RabbitTemplate(connectionFactory());
RetryTemplate retryTemplate = new RetryTemplate();
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
Expand Down Expand Up @@ -1923,7 +1923,7 @@ public class ExampleAmqpConfiguration {
}
@Bean
public ConnectionFactory rabbitConnectionFactory() {
public CachingConnectionFactory rabbitConnectionFactory() {
CachingConnectionFactory connectionFactory =
new CachingConnectionFactory("localhost");
connectionFactory.setUsername("guest");
Expand Down Expand Up @@ -2458,7 +2458,7 @@ Starting with version 2.3, you can override the factory converter by specifying
[source, java]
----
@Bean
public MessageConverter jsonConverter() {
public Jackson2JsonMessageConverter jsonConverter() {
return new Jackson2JsonMessageConverter();
}
Expand Down Expand Up @@ -2502,7 +2502,7 @@ public class AppConfig implements RabbitListenerConfigurer {
}
@Bean
public ConversionService myConversionService() {
public DefaultConversionService myConversionService() {
DefaultConversionService conv = new DefaultConversionService();
conv.addConverter(mySpecialConverter());
return conv;
Expand Down Expand Up @@ -4613,7 +4613,7 @@ The following listing shows the code for `AbstractStockRabbitConfiguration`:
public abstract class AbstractStockAppRabbitConfiguration {
@Bean
public ConnectionFactory connectionFactory() {
public CachingConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory =
new CachingConnectionFactory("localhost");
connectionFactory.setUsername("guest");
Expand All @@ -4630,7 +4630,7 @@ public abstract class AbstractStockAppRabbitConfiguration {
}
@Bean
public MessageConverter jsonMessageConverter() {
public Jackson2JsonMessageConverter jsonMessageConverter() {
return new Jackson2JsonMessageConverter();
}
Expand Down Expand Up @@ -4786,7 +4786,7 @@ The following example shows how to do so:
public static class Config {
@Bean
public ConnectionFactory cf() {
public CachingConnectionFactory cf() {
return new CachingConnectionFactory("localhost");
}
Expand Down
4 changes: 2 additions & 2 deletions src/reference/asciidoc/quick-tour.adoc
Expand Up @@ -135,12 +135,12 @@ String foo = (String) template.receiveAndConvert("myqueue");
public class RabbitConfiguration {
@Bean
public ConnectionFactory connectionFactory() {
public CachingConnectionFactory connectionFactory() {
return new CachingConnectionFactory("localhost");
}
@Bean
public AmqpAdmin amqpAdmin() {
public RabbitAdmin amqpAdmin() {
return new RabbitAdmin(connectionFactory());
}
Expand Down
2 changes: 1 addition & 1 deletion src/reference/asciidoc/sample-apps.adoc
Expand Up @@ -28,7 +28,7 @@ The following listing shows how the connection factory is created:
[source,java]
----
@Bean
public ConnectionFactory connectionFactory() {
public CachingConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory =
new CachingConnectionFactory("localhost");
connectionFactory.setUsername("guest");
Expand Down
11 changes: 3 additions & 8 deletions src/reference/asciidoc/testing.adoc
Expand Up @@ -522,20 +522,15 @@ IMPORTANT: The method must be called before invoking any of the `isRunning()` st
Variable values are applied to all instances created after this invocation.
Invoke `clearEnvironmentVariableOverrides()` to reset the rule to use defaults (including any actual environment variables).

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

====
[source, java]
----
@Bean
public ConnectionFactory rabbitConnectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setHost(brokerRunning.getHostName());
connectionFactory.setPort(brokerRunning.getPort());
connectionFactory.setUsername(brokerRunning.getUser());
connectionFactory.setPassword(brokerRunning.getPassword());
return connectionFactory;
public CachingConnectionFactory rabbitConnectionFactory() {
return new CachingConnectionFactory(brokerRunning.getConnectionFactory());
}
----
====
Expand Down

0 comments on commit 2c91196

Please sign in to comment.