wordpress商城必备软件,重庆seo优化推广,extjs网站开发,网站制作公司 沈阳RabbitMq不支持修改已经存在的队列和交换机参数#xff0c;可以通过创建失败#xff0c;捕获异常信息#xff0c;然后删除原队列或交换机#xff0c;然后重新创建#xff0c;以达到修改参数的功能。package com.sky.study.delete;import java.io.IOException;import java.…RabbitMq不支持修改已经存在的队列和交换机参数可以通过创建失败捕获异常信息然后删除原队列或交换机然后重新创建以达到修改参数的功能。package com.sky.study.delete;import java.io.IOException;import java.util.concurrent.TimeoutException;import com.rabbitmq.client.AMQP;import com.rabbitmq.client.AMQP.Queue.DeclareOk;import com.rabbitmq.client.Channel;import com.rabbitmq.client.Connection;import com.sky.study.ConnectionUtil;public class DynamicDelete {private final static String queueNameceshi_queue;public static void main(String[] args) throws Exception {Connection connection ConnectionUtil.getConnection();Channel channel connection.createChannel();DeclareOk ss declearQueue(channel,queueName);System.out.println(ss);channel.close();connection.close();}public static DeclareOk declearQueue(Channel channel, String queueName) throws Exception {Connection connection1 ConnectionUtil.getConnection();Channel channel1 connection1.createChannel();try {channel1.queueDeclare(queueName,true, false, false, null);} catch (IOException e) {try {channel1.close();} catch (Exception ex) {}try {connection1.close();} catch (Exception ex) {}connection1 ConnectionUtil.getConnection();channel1 connection1.createChannel();channel1.queueDelete(queueName);try {channel1.close();} catch (Exception ex) {}try {connection1.close();} catch (Exception ex) {}} finally {try {channel1.close();} catch (Exception ex) {}try {connection1.close();} catch (Exception ex) {}}DeclareOk declareOk channel.queueDeclare(queueName, true, false, false, null);return declareOk;}public static AMQP.Exchange.DeclareOk declearExchange(Channel channel, String exchangeName, String exchangeMode) throws IOException, TimeoutException {//exchangeDeclare 交换机名字类型是否持久化不使用时是否自动删除是否是内部的(不能被客户端使用)其他参数Connection connection1 ConnectionUtil.getConnection();Channel channel1 connection1.createChannel();AMQP.Exchange.DeclareOk declareOk;try {channel1.exchangeDeclare(exchangeName, exchangeMode, true, false, false, null);} catch (IOException e) {try {channel1.close();} catch (Exception ex) {}try {connection1.close();} catch (Exception ex) {}connection1 ConnectionUtil.getConnection();channel1 connection1.createChannel();channel1.exchangeDelete(exchangeName);try {channel1.close();} catch (Exception ex) {}try {connection1.close();} catch (Exception ex) {}} finally {try {channel1.close();} catch (Exception ex) {}try {connection1.close();} catch (Exception ex) {}}declareOk channel.exchangeDeclare(exchangeName, exchangeMode,true, false, false, null);return declareOk;}}