zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.changhong.epc.admin.config;
 
import com.changhong.epc.admin.service.mq.AutoFormConsumer;
import com.changhong.epc.constter.base.MQConst;
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;
    }
 
}