Skip to content

Commit

Permalink
merge pull alibaba#5089
Browse files Browse the repository at this point in the history
  • Loading branch information
agapple committed Apr 3, 2024
1 parent c0ff058 commit caa46f3
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,18 @@ public void init(Properties properties) {
try {
connect = factory.newConnection();
channel = connect.createChannel();
channel.queueDeclare(rabbitMQProperties.getQueue(), true, false, false, null);
channel.exchangeDeclare(rabbitMQProperties
.getExchange(), rabbitMQProperties.getDeliveryMode(), true, false, false, null);
channel.queueBind(rabbitMQProperties.getQueue(),
rabbitMQProperties.getExchange(),
rabbitMQProperties.getRoutingKey());

String queue = rabbitMQProperties.getQueue();
String exchange = rabbitMQProperties.getExchange();
String deliveryMode = rabbitMQProperties.getDeliveryMode();
String routingKey = rabbitMQProperties.getRoutingKey();
if (!StringUtils.isEmpty(queue)) {
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) {
throw new CanalException("Start RabbitMQ producer error", ex);
}
Expand Down

0 comments on commit caa46f3

Please sign in to comment.