|
|
|
@ -16,7 +16,6 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.amqp;
|
|
|
|
|
|
|
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
|
|
import org.springframework.amqp.core.AmqpAdmin;
|
|
|
|
|
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
|
|
|
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|
|
|
@ -31,30 +30,49 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
|
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <P> {@link EnableAutoConfiguration Auto-configuration} for {@link RabbitTemplate}.
|
|
|
|
|
*
|
|
|
|
|
* <p> This configuration class is active only when the RabbitMQ and Spring AMQP client libraries are on the classpath.
|
|
|
|
|
*
|
|
|
|
|
* <P> Registers a {@link org.springframework.amqp.rabbit.core.RabbitTemplate RabbitTemplate} instance if there
|
|
|
|
|
* is no other bean of the same type in the context. Registers a {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory CachingConnectionFactory}
|
|
|
|
|
* instance if there is no other bean of the same type in the context.
|
|
|
|
|
*
|
|
|
|
|
* <p> Registers a {@link org.springframework.amqp.core.AmqpAdmin } instance as long as {@literal spring.rabbitmq.dynamic=true}.
|
|
|
|
|
*
|
|
|
|
|
* {@link EnableAutoConfiguration Auto-configuration} for {@link RabbitTemplate}.
|
|
|
|
|
* <p>
|
|
|
|
|
* The {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory} honors the following properties:
|
|
|
|
|
* {@literal spring.rabbitmq.port} is used to specify the port to which the client should connect, and defaults to 5672.
|
|
|
|
|
* {@literal spring.rabbitmq.username} is used to specify the (optional) username, and
|
|
|
|
|
* {@literal spring.rabbitmq.password} is used to specify the (optional) password.
|
|
|
|
|
* {@literal spring.rabbitmq.host} is used to specify the host, and defaults to {@literal localhost}.
|
|
|
|
|
* {@literal spring.rabbitmq.virtualHost} is used to specify the (optional) virtual host to which the client should connect.
|
|
|
|
|
*
|
|
|
|
|
* This configuration class is active only when the RabbitMQ and Spring AMQP client
|
|
|
|
|
* libraries are on the classpath.
|
|
|
|
|
* <P>
|
|
|
|
|
* Registers the following beans:
|
|
|
|
|
* <ul>
|
|
|
|
|
* <li>
|
|
|
|
|
* {@link org.springframework.amqp.rabbit.core.RabbitTemplate RabbitTemplate} if there is
|
|
|
|
|
* no other bean of the same type in the context.</li>
|
|
|
|
|
* <li>
|
|
|
|
|
* {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory
|
|
|
|
|
* CachingConnectionFactory} instance if there is no other bean of the same type in the
|
|
|
|
|
* context.</li>
|
|
|
|
|
* <li>
|
|
|
|
|
* {@link org.springframework.amqp.core.AmqpAdmin } instance as long as
|
|
|
|
|
* {@literal spring.rabbitmq.dynamic=true}.</li>
|
|
|
|
|
* </ul>
|
|
|
|
|
* <p>
|
|
|
|
|
* The {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory} honors
|
|
|
|
|
* the following properties:
|
|
|
|
|
* <ul>
|
|
|
|
|
* <li>
|
|
|
|
|
* {@literal spring.rabbitmq.port} is used to specify the port to which the client should
|
|
|
|
|
* connect, and defaults to 5672.</li>
|
|
|
|
|
* <li>
|
|
|
|
|
* {@literal spring.rabbitmq.username} is used to specify the (optional) username.</li>
|
|
|
|
|
* <li>
|
|
|
|
|
* {@literal spring.rabbitmq.password} is used to specify the (optional) password.</li>
|
|
|
|
|
* <li>
|
|
|
|
|
* {@literal spring.rabbitmq.host} is used to specify the host, and defaults to
|
|
|
|
|
* {@literal localhost}.</li>
|
|
|
|
|
* <li>{@literal spring.rabbitmq.virtualHost} is used to specify the (optional) virtual
|
|
|
|
|
* host to which the client should connect.</li>
|
|
|
|
|
* </ul>
|
|
|
|
|
* @author Greg Turnquist
|
|
|
|
|
* @author Josh Long
|
|
|
|
|
*/
|
|
|
|
|
@Configuration
|
|
|
|
|
@ConditionalOnClass({RabbitTemplate.class, Channel.class})
|
|
|
|
|
@ConditionalOnClass({ RabbitTemplate.class, Channel.class })
|
|
|
|
|
@EnableConfigurationProperties(RabbitProperties.class)
|
|
|
|
|
public class RabbitAutoConfiguration {
|
|
|
|
|
|
|
|
|
|