diff --git a/src/reference/asciidoc/amqp.adoc b/src/reference/asciidoc/amqp.adoc index d322a8a502..ab60320156 100644 --- a/src/reference/asciidoc/amqp.adoc +++ b/src/reference/asciidoc/amqp.adoc @@ -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"); } @@ -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()); @@ -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()), @@ -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(); @@ -1923,7 +1923,7 @@ public class ExampleAmqpConfiguration { } @Bean - public ConnectionFactory rabbitConnectionFactory() { + public CachingConnectionFactory rabbitConnectionFactory() { CachingConnectionFactory connectionFactory = new CachingConnectionFactory("localhost"); connectionFactory.setUsername("guest"); @@ -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(); } @@ -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; @@ -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"); @@ -4630,7 +4630,7 @@ public abstract class AbstractStockAppRabbitConfiguration { } @Bean - public MessageConverter jsonMessageConverter() { + public Jackson2JsonMessageConverter jsonMessageConverter() { return new Jackson2JsonMessageConverter(); } @@ -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"); } diff --git a/src/reference/asciidoc/quick-tour.adoc b/src/reference/asciidoc/quick-tour.adoc index a00aceeb2e..af2aa94e2a 100644 --- a/src/reference/asciidoc/quick-tour.adoc +++ b/src/reference/asciidoc/quick-tour.adoc @@ -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()); } diff --git a/src/reference/asciidoc/sample-apps.adoc b/src/reference/asciidoc/sample-apps.adoc index af07a07fda..b75dc60181 100644 --- a/src/reference/asciidoc/sample-apps.adoc +++ b/src/reference/asciidoc/sample-apps.adoc @@ -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"); diff --git a/src/reference/asciidoc/testing.adoc b/src/reference/asciidoc/testing.adoc index 49fe1d4d30..5a3c314fc6 100644 --- a/src/reference/asciidoc/testing.adoc +++ b/src/reference/asciidoc/testing.adoc @@ -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()); } ---- ====