0
的很慢的表现我已经遇到了春天引导消费者的烦恼。我比较了两位消费者的工作。 首先消费者:弹簧AMQP comsumer
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) {
}
}
有用于安装弹簧引导消费者没有配置文件,一切都默认。 在我的电脑第一个作品的速度快10倍。可能是什么问题?
感谢。它解决了这个问题。 – GoodYar
谢谢。我看到你是新来的 - 如果你“接受”答案(点击表决按钮左下方的勾号/复选标记),它将帮助其他人寻找答案。 –