在 JSP 中,当我到达“QueueingConsumer.Delivery Delivery = consumer.nextDelivery()”时,页面被卡住了加载。消息已被使用,但 jsp 不会加载,也不会出错。请帮忙
String QUEUE_NAME = "hello";
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
out.println(" [*] Waiting for messages. To exit press CTRL+C");
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(QUEUE_NAME, true, consumer);
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
out.println(" [x] Received '" + message + "'");
}