|
|
@@ -35,7 +35,7 @@ public class RabbitConsumer implements PojoRequestHandler<Map<String, Object>, V
|
|
|
try (Connection connection = RabbitMQHelper.createConnection();
|
|
|
Channel channel = RabbitMQHelper.createChannel(connection, queueName)) {
|
|
|
|
|
|
- startConsumer(channel);
|
|
|
+ startConsumer(channel,queueName);
|
|
|
log.info("RabbitMQ 消费者启动成功");
|
|
|
|
|
|
Object val = input.get("waitSeconds");
|
|
|
@@ -54,11 +54,11 @@ public class RabbitConsumer implements PojoRequestHandler<Map<String, Object>, V
|
|
|
/**
|
|
|
* 启动消费者
|
|
|
*/
|
|
|
- private void startConsumer(Channel channel) throws IOException {
|
|
|
+ private void startConsumer(Channel channel,String queueName) throws IOException {
|
|
|
channel.basicQos(1);
|
|
|
|
|
|
- log.info("开始消费队列: {}", QUEUE_NAME);
|
|
|
- channel.basicConsume(QUEUE_NAME, false, (consumerTag, delivery) -> {
|
|
|
+ log.info("开始消费队列: {}", queueName);
|
|
|
+ channel.basicConsume(queueName, false, (consumerTag, delivery) -> {
|
|
|
String message = new String(delivery.getBody(), StandardCharsets.UTF_8);
|
|
|
log.info("收到消息: {}", message);
|
|
|
|