|
@@ -1,32 +1,28 @@
|
|
|
-package cn.reghao.autodop.dmaster.common.mq;
|
|
|
|
|
|
|
+package cn.reghao.autodop.common.mq;
|
|
|
|
|
|
|
|
-import cn.reghao.autodop.common.utils.NetworkUtil;
|
|
|
|
|
import org.springframework.amqp.core.Queue;
|
|
import org.springframework.amqp.core.Queue;
|
|
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|
|
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
|
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
|
|
-import java.net.SocketException;
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author reghao
|
|
* @author reghao
|
|
|
* @date 2020-09-04 10:57:56
|
|
* @date 2020-09-04 10:57:56
|
|
|
*/
|
|
*/
|
|
|
@Configuration
|
|
@Configuration
|
|
|
-public class RabbitConfig {
|
|
|
|
|
|
|
+public class RabbitConsumerConfig {
|
|
|
@Bean
|
|
@Bean
|
|
|
- public Queue dagentQueue() throws SocketException {
|
|
|
|
|
- String address = NetworkUtil.hostAddr().get(0).getIpv4();
|
|
|
|
|
- String queueName = "dmaster@" + address;
|
|
|
|
|
|
|
+ public Queue dagentQueue() {
|
|
|
|
|
+ String queueName = "dmaster";
|
|
|
return new Queue(queueName, true);
|
|
return new Queue(queueName, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Bean
|
|
@Bean
|
|
|
- public SimpleMessageListenerContainer messageListenerContainer(ConnectionFactory connectionFactory) throws SocketException {
|
|
|
|
|
|
|
+ public SimpleMessageListenerContainer messageListenerContainer(ConnectionFactory connectionFactory) {
|
|
|
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
|
|
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
|
|
|
container.setConnectionFactory(connectionFactory);
|
|
container.setConnectionFactory(connectionFactory);
|
|
|
- container.setMessageListener(new MessageDispatcher());
|
|
|
|
|
|
|
+ container.setMessageListener(new RabbitConsumer());
|
|
|
container.addQueues(dagentQueue());
|
|
container.addQueues(dagentQueue());
|
|
|
return container;
|
|
return container;
|
|
|
}
|
|
}
|