我想增加redismessagelistenercontainer上的消息侦听器数量。我的redisconfig代码如下所示:
@Configuration
public class RedisConfig {
@Bean
MessageListener messageListener() {
return new MessageListenerAdapter(new RedisMessageListener());
}
@Bean
RedisMessageListenerContainer redisContainer() {
final RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(jedisConnectionFactory());
container.addMessageListener(messageListener(), topic());
// here I want multiple copies of same messageListener bean registered
return container;
}
}
我可以很容易地用rabbitmq扩展消费者,比如:
@Bean
MessageListenerContainer messageListenerContainer() {
SimpleMessageListenerContainer simpleMessageListenerContainer = new SimpleMessageListenerContainer(connectionFactory());
simpleMessageListenerContainer.setQueues(myQueue());
simpleMessageListenerContainer.setMessageListener(new RabbitMQListener());
// here
simpleMessageListenerContainer.setConcurrentConsumers(CONSUMER_SIZE);
return simpleMessageListenerContainer;
}
我希望redismessagelistenercontainer也一样。如何订阅多个并发侦听器( MessageListener
)同一个豆子?
暂无答案!
目前还没有任何答案,快来回答吧!