| | |
| | | package org.apereo.cas.web.landtool.rabbitmq.config; |
| | | |
| | | import org.springframework.amqp.core.Binding; |
| | | import org.springframework.amqp.core.BindingBuilder; |
| | | import org.springframework.amqp.core.Queue; |
| | | import org.springframework.amqp.core.TopicExchange; |
| | | import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; |
| | | import org.springframework.amqp.rabbit.connection.ConnectionFactory; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | @Configuration |
| | | public class RabbitConfig { |
| | | @Autowired |
| | | private RabbitMQProperties rabbitConfig; |
| | | |
| | | // @Bean |
| | | // public ConnectionFactory connectionFactory() { |
| | | // CachingConnectionFactory connectionFactory = new CachingConnectionFactory(); |
| | | // connectionFactory.setAddresses("192.168.0.19:5672"); |
| | | // connectionFactory.setUsername("landtool"); |
| | | // connectionFactory.setPassword("lt"); |
| | | // connectionFactory.setVirtualHost("/radar"); |
| | | // connectionFactory.setPublisherConfirms(true); |
| | | // return connectionFactory; |
| | | // } |
| | | // |
| | | // @Bean |
| | | // public RabbitTemplate rabbitTemplate() { |
| | | // RabbitTemplate template = new RabbitTemplate(connectionFactory()); |
| | | // return template; |
| | | // } |
| | | |
| | | // //声明队列 |
| | | // @Bean |
| | | // public Queue queueMessage() { |
| | | // return new Queue("topic.message"); |
| | | // } |
| | | |
| | | //声明交互器 |
| | | private RabbitMqProperties rabbitConfig; |
| | | |
| | | /** |
| | | * 声明交互器 |
| | | * @return |
| | | */ |
| | | @Bean |
| | | TopicExchange topicExchange() { |
| | | return new TopicExchange(rabbitConfig.getRmqExchangeName(),false,false); |
| | | } |
| | | |
| | | // /** |
| | | // * 将队列topic.message与exchange绑定,binding_key为topic.message,就是完全匹配 |
| | | // * @param queueMessage |
| | | // * @param exchange |
| | | // * @return |
| | | // */ |
| | | // @Bean |
| | | // Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange) { |
| | | // return BindingBuilder.bind(queueMessage).to(exchange).with("topic.#"); |
| | | // } |
| | | } |