You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sdny-order/order-management-consumer/src/test/java/sims_api_processRabbitMq.java

124 lines
5.6 KiB

import com.dxhy.order.constant.ConfigureConstant;
import com.dxhy.order.constant.OrderInfoEnum;
import com.dxhy.order.utils.AesEncryptUtil;
import com.dxhy.order.utils.HttpUtils;
import com.dxhy.order.utils.JsonUtils;
import com.dxhy.order.consumer.model.page.PageInterfaceUpdateRabbitMq;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 线上数据rabbitmq
*
* @author ZSC-DXHY-PC
* @date 创建时间: 2018/12/24 22:55
*/
public class sims_api_processRabbitMq {
public static void main(String[] args) throws IOException {
//操作队列监听
operateQueueListener();
//按税号重新缓存队列配置
// reCacheSysQueueConfig();
//重新缓存渠道队列配置
// reCacheSysQdQueueConfig();
}
private static void operateQueueListener() throws IOException {
/*
* 格式:队列名
*/
List<String> gbk = FileUtils.readLines(new File("d://test/processRabbitMq.txt"), StandardCharsets.UTF_8);
List<String> resultList = new ArrayList<>();
for (int i = 0; i < gbk.size(); i++) {
String[] split = gbk.get(i).split(",");
String url = "https://sims.ele-cloud.com/order-api/api/updateRabbitMq";
url = "https://sims.dxyun.com/order-api/api/updateRabbitMq";
// url = "http://10.1.1.222:8087/order-api/api/updateRabbitMq";
// url = "http://10.1.31.217:8087/order-api/api/updateRabbitMq";
// String url = "http://10.1.29.55:8087/order-api/api/updateRabbitMq";
Map<String, String> headMap = new HashMap<>(2);
headMap.put("Content-Type", ConfigureConstant.STRING_APPLICATION_JSON);
PageInterfaceUpdateRabbitMq pageInterfaceUpdateRabbitMq = new PageInterfaceUpdateRabbitMq();
//操作类型(0:停止监听;1:删除监听;2:重启监听)
pageInterfaceUpdateRabbitMq.setType("2");
List<String> queueNameList = new ArrayList<>();
queueNameList.add(split[0]);
pageInterfaceUpdateRabbitMq.setQueueNameList(queueNameList);
String content = AesEncryptUtil.encrypt(JsonUtils.getInstance().toJsonString(pageInterfaceUpdateRabbitMq), "dtfbjpqla0dn7pmb");
String result = "{\"type\":\"0\",\"content\":\"" + content + "\"}";
String post = HttpUtils.doPostWithHeader(url, result, headMap);
Map map = JsonUtils.getInstance().parseObject(post, Map.class);
System.out.println(post);
System.out.println("执行了:" + (i + 1));
resultList.add(split[0] + "," + map.get("msg"));
}
for (String s : resultList) {
System.out.println(s);
}
}
/**
* 按税号重新缓存队列配置
*/
private static void reCacheSysQueueConfig() throws IOException {
/*
* 格式:税号
*/
List<String> gbk = FileUtils.readLines(new File("d://test/processRabbitMq.txt"), StandardCharsets.UTF_8);
String url = "https://sims.ele-cloud.com/order-api/api/updateRabbitMq";
// url = "http://10.1.1.222:8087/order-api/api/updateRabbitMq";
// String url = "http://10.1.29.55:8087/order-api/api/updateRabbitMq";
Map<String, String> headMap = new HashMap<>(2);
headMap.put("Content-Type", ConfigureConstant.STRING_APPLICATION_JSON);
PageInterfaceUpdateRabbitMq pageInterfaceUpdateRabbitMq = new PageInterfaceUpdateRabbitMq();
//操作类型(0:停止监听;1:删除监听;2:重启监听;3:重新缓存队列配置;4:重新缓存渠道队列配置)
pageInterfaceUpdateRabbitMq.setType(OrderInfoEnum.OPERATE_RABBITMQ_BY_FANOUT_TYPE_3.getKey());
// pageInterfaceUpdateRabbitMq.setShList(gbk);
String content = AesEncryptUtil.encrypt(JsonUtils.getInstance().toJsonString(pageInterfaceUpdateRabbitMq), "dtfbjpqla0dn7pmb");
String result = "{\"type\":\"0\",\"content\":\"" + content + "\"}";
String post = HttpUtils.doPostWithHeader(url, result, headMap);
Map map = JsonUtils.getInstance().parseObject(post, Map.class);
System.out.println(post);
}
/**
* 重新缓存渠道队列配置
*/
private static void reCacheSysQdQueueConfig() throws IOException {
String url = "http://10.1.29.55:8087/order-api/api/updateRabbitMq";
Map<String, String> headMap = new HashMap<>(2);
headMap.put("Content-Type", ConfigureConstant.STRING_APPLICATION_JSON);
PageInterfaceUpdateRabbitMq pageInterfaceUpdateRabbitMq = new PageInterfaceUpdateRabbitMq();
//操作类型(0:停止监听;1:删除监听;2:重启监听;3:重新缓存队列配置;4:重新缓存渠道队列配置)
pageInterfaceUpdateRabbitMq.setType(OrderInfoEnum.OPERATE_RABBITMQ_BY_FANOUT_TYPE_4.getKey());
List<String> qdList = FileUtils.readLines(new File("d://data/dxhy/reCacheSysQdQueueConfig.txt"), StandardCharsets.UTF_8);
pageInterfaceUpdateRabbitMq.setQdList(qdList);
String content = AesEncryptUtil.encrypt(JsonUtils.getInstance().toJsonString(pageInterfaceUpdateRabbitMq), "dtfbjpqla0dn7pmb");
String request = "{\"type\":\"0\",\"content\":\"" + content + "\"}";
String response = HttpUtils.doPostWithHeader(url, request, headMap);
Map map = JsonUtils.getInstance().parseObject(response, Map.class);
System.out.println(response);
System.out.println(map.get("msg"));
}
}