fixed NEP when Upgrading to 1.1.7 from old version (#5089)

Co-authored-by: Allen GAN <allen.gan@schindler.com>
This commit is contained in:
ganxu330
2024-04-03 10:37:58 +08:00
committed by GitHub
parent 9e715b95bc
commit 4c906702a6
2 changed files with 18 additions and 6 deletions

View File

@@ -72,12 +72,23 @@ public class CanalRabbitMQProducer extends AbstractMQProducer implements CanalMQ
try { try {
connect = factory.newConnection(); connect = factory.newConnection();
channel = connect.createChannel(); channel = connect.createChannel();
channel.queueDeclare(rabbitMQProperties.getQueue(), true, false, false, null); String queue=rabbitMQProperties.getQueue();
channel.exchangeDeclare(rabbitMQProperties String exchange=rabbitMQProperties.getExchange();
.getExchange(), rabbitMQProperties.getDeliveryMode(), true, false, false, null); String deliveryMode=rabbitMQProperties.getDeliveryMode();
channel.queueBind(rabbitMQProperties.getQueue(), String routingKey=rabbitMQProperties.getRoutingKey();
rabbitMQProperties.getExchange(), if(!StringUtils.isEmpty(queue))
rabbitMQProperties.getRoutingKey()); {
channel.queueDeclare(queue, true, false, false, null);
}
if(!StringUtils.isEmpty(queue)
&&!StringUtils.isEmpty(exchange)
&&!StringUtils.isEmpty(deliveryMode)
&&!StringUtils.isEmpty(routingKey))
{
channel.exchangeDeclare(exchange, deliveryMode, true, false, false, null);
channel.queueBind(queue,exchange,routingKey);
}
} catch (IOException | TimeoutException ex) { } catch (IOException | TimeoutException ex) {
throw new CanalException("Start RabbitMQ producer error", ex); throw new CanalException("Start RabbitMQ producer error", ex);

View File

@@ -177,6 +177,7 @@ rabbitmq.exchange =
rabbitmq.username = rabbitmq.username =
rabbitmq.password = rabbitmq.password =
rabbitmq.deliveryMode = rabbitmq.deliveryMode =
rabbitmq.queue =
################################################## ##################################################