package com.changhong.epc.parsing.config;
|
|
import com.changhong.epc.constter.base.MQConst;
|
import com.changhong.epc.parsing.service.mq.AutoFormConsumer;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.listener.PatternTopic;
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
|
|
import javax.annotation.Resource;
|
|
@Configuration
|
public class MQConsumerConfig implements MQConst {
|
|
@Resource
|
private AutoFormConsumer autoFormConsumer;
|
|
/**
|
* 创建连接工厂
|
* @param connectionFactory
|
* @return
|
*/
|
@Bean
|
public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory){
|
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
container.setConnectionFactory(connectionFactory);
|
container.addMessageListener(new MessageListenerAdapter(autoFormConsumer) ,new PatternTopic(AUTO_NUMBER));
|
return container;
|
}
|
|
}
|