我一直在使用spring-boot consumer遇到麻烦。我比较了两个消费者的工作。第一消费者:
import com.rabbitmq.client.*;
import java.io.IOException;
public class Recv {
private final static String QUEUE_NAME = "hello";
public static void main(String[] argv) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
Consumer consumer = new DefaultConsumer(channel) {
@Override
public void handleDelivery(String consumerTag, Envelope envelope,
AMQP.BasicProperties properties, byte[] body) throws IOException {
}
};
channel.basicConsume(QUEUE_NAME, true, consumer);
}
}第二消费者:
@Controller
public class Consumer {
@RabbitListener(queues = "hello")
public void processMessage(Message message) {
}
}没有为spring-boot消费者安装配置文件,一切都是默认的。在我的电脑上,第一个速度快了10倍。可能的问题是什么?
https://stackoverflow.com/questions/41316015
复制相似问题