Commit a93edcf7 authored by yanzg's avatar yanzg

手动消费

parent 6fb45c0e
package com.yanzuoguang.mq.base;
import com.yanzuoguang.mq.base.consumer.ConsumerSimpleMessageListenerContainer;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
......@@ -25,6 +26,7 @@ public class MqConsumeDynamic {
public SimpleMessageListenerContainer init(String queueName, ChannelAwareMessageListener messageListener) {
ConsumerSimpleMessageListenerContainer container = new ConsumerSimpleMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
container.setQueueNames(queueName);
container.setConcurrentConsumers(onOfConsumer);
container.setMessageListener(new MessageListenerAdapter(messageListener));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment