mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
merge pull #5089
This commit is contained in:
@@ -82,13 +82,18 @@ 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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user