rabbitmq笔记
// 创建队列(包括参数) try { // 没有异常说明这个queue存在 rabbitTemplate.getConnectionFactory().createConnection().createChannel(false) .queueDeclarePassive(queueName); // continue; } catch (java.io.IOException e) { // 新建队列 rabbitTemplate.getConnectionFactory().createConnection().createChannel(false).queueDeclare(queueName, true, false, false, null); }
// 新建交换机 try { // 没有异常说明这个exchange存在 rabbitTemplate.getConnectionFactory().createConnection().createChannel(false) .exchangeDeclarePassive(exchange); } catch (java.io.IOException e) { // exchange不存在 rabbitTemplate.getConnectionFactory().createConnection().createChannel(false).exchangeDeclare(exchange, "topic", true); }
rabbitTemplate.getConnectionFactory().createConnection().createChannel(false).queueUnbind(originName, originExchange, key);
rabbitTemplate.getConnectionFactory().createConnection().createChannel(false).queueBind(queueName, exchange, key);
try { rabbitTemplate.getConnectionFactory().createConnection().createChannel(false).queueDelete(originName); } catch (AmqpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
越努力越幸运~ 加油ヾ(◍°∇°◍)ノ゙