public void createMQ(String queueName) { try (Connection connection = connectionFactory.newConnection()) { //获取一个链接 //从连接中获取一个通道 Channel channel = connection.createChannel(); channel.exchangeDeclare("testExchange", ExchangeTypes.TOPIC, true); channel.queueDeclare(queueName, true, false, false, null); channel.queueBind(queueName,"testExchange",queueName); channel.close(); logger.info("createMQ 成功"); } catch (IOException e) { logger.error("createMQ --> IOException", e); e.printStackTrace(); } catch (TimeoutException e) { logger.error("createMQ --> TimeoutException", e); e.printStackTrace(); } }