RabbitMQ相关调研
这个提交包含在:
父节点
fb4f76c9e4
当前提交
ad903609ee
二进制
.mvn/wrapper/maven-wrapper.jar
vendored
二进制
.mvn/wrapper/maven-wrapper.jar
vendored
二进制文件未显示。
18
.mvn/wrapper/maven-wrapper.properties
vendored
18
.mvn/wrapper/maven-wrapper.properties
vendored
@ -1,18 +0,0 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
|
||||
5
pom.xml
5
pom.xml
@ -66,6 +66,11 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>29.0-jre</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -0,0 +1,280 @@
|
||||
package cn.org.bjca.trust.java.imserver;
|
||||
|
||||
import cn.org.bjca.trust.java.imserver.common.json.GsonImplHelp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.ResponseErrorHandler;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import static org.springframework.http.HttpMethod.GET;
|
||||
import static org.springframework.http.HttpMethod.POST;
|
||||
|
||||
@Slf4j
|
||||
public class CurlUtil {
|
||||
// 请求结果
|
||||
private String result = "";
|
||||
|
||||
/*** RestTemplate 请求构造内部类*/
|
||||
public static class Builder {
|
||||
// 请求URL
|
||||
private String url;
|
||||
// basic auth用户名
|
||||
private String userName;
|
||||
// basic auth密码
|
||||
private String passWord;
|
||||
// 请求方式 默认为GET
|
||||
private HttpMethod methodType = GET;
|
||||
// 请求参数
|
||||
private HashMap<String, String> paramMap;
|
||||
// 请求header头
|
||||
private HashMap<String, String> headerMap;
|
||||
// RestTemplate 实例
|
||||
private RestTemplate client;
|
||||
// header头实例
|
||||
private HttpHeaders headers;
|
||||
// 请求结果
|
||||
private String result;
|
||||
|
||||
/*** 基础请求* @param url*/
|
||||
public Builder(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
/*** basic auth 认证类型请求* @param url* @param userName* @param passWord*/
|
||||
public Builder(String url, String userName, String passWord) {
|
||||
this.url = url;
|
||||
this.userName = userName;
|
||||
this.passWord = passWord;
|
||||
}
|
||||
|
||||
/*** 添加参数* @param key 参数key* @param value 参数内容* @return Builder*/
|
||||
public Builder addParam(String key, String value) {
|
||||
if (paramMap == null) {
|
||||
paramMap = new LinkedHashMap<>(16);
|
||||
}
|
||||
paramMap.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*** 添加header参数* @param key 参数key* @param value 参数内容* @return Builder*/
|
||||
public Builder addHeader(String key, String value) {
|
||||
if (headerMap == null) {
|
||||
headerMap = new LinkedHashMap<>(16);
|
||||
}
|
||||
headerMap.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*** GET 请求* @return Curl*/
|
||||
public CurlUtil get() {
|
||||
this.methodType = GET;
|
||||
this.getResponse(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
return new CurlUtil(this);
|
||||
}
|
||||
|
||||
/*** post 请求* @return Curl*/
|
||||
public CurlUtil post() {
|
||||
this.methodType = POST;
|
||||
this.getResponse(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
return new CurlUtil(this);
|
||||
}
|
||||
|
||||
/*** raw 方式提交json 请求* @return Curl*/
|
||||
public CurlUtil postRaw() {
|
||||
HashMap<String, Object> paramRawMap = new HashMap<>();
|
||||
return this.raw(paramRawMap);
|
||||
}
|
||||
|
||||
/*** raw 方式提交json 请求* @param paramRawMap Map数据* @return Curl*/
|
||||
public CurlUtil postRaw(HashMap<String, Object> paramRawMap) {
|
||||
return this.raw(paramRawMap);
|
||||
}
|
||||
|
||||
/*** RAW 请求* @param paramRawMap 参数* @return*/
|
||||
private CurlUtil raw(HashMap<String, Object> paramRawMap) {
|
||||
client = new RestTemplate();
|
||||
client.setErrorHandler(new RestErrorHandler());
|
||||
headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
this.setHeadersMapData();
|
||||
this.responseRawExchange(GsonImplHelp.get().toJson(paramRawMap));
|
||||
return new CurlUtil(this);
|
||||
}
|
||||
|
||||
/*** 初始化请求体* @param type 请求类型*/
|
||||
private void getResponse(MediaType type) {
|
||||
client = new RestTemplate();
|
||||
client.setErrorHandler(new RestErrorHandler());
|
||||
headers = new HttpHeaders();
|
||||
headers.setContentType(type);
|
||||
this.setHeadersMapData();
|
||||
MultiValueMap<String, String> params = this.setHttpMethodParamsMap();
|
||||
this.responseExchange(params);
|
||||
}
|
||||
|
||||
/*** 设置header头数据*/
|
||||
private void setHeadersMapData() {
|
||||
if (headerMap != null) {
|
||||
headerMap.forEach((k, v) -> {
|
||||
this.headers.set(k, v);
|
||||
});
|
||||
}
|
||||
// 设置basic auth请求方式认证信息
|
||||
if (this.userName != null && this.passWord != null) {
|
||||
String secretKey = this.userName + ":" + this.passWord;
|
||||
String authValue = "Basic " + Base64.getEncoder().encodeToString(secretKey.getBytes());
|
||||
this.headers.set("Authorization", authValue);
|
||||
}
|
||||
}
|
||||
|
||||
/*** 组装请求体参数* @return MultiValueMap<String, String>*/
|
||||
private MultiValueMap<String, String> setHttpMethodParamsMap() {
|
||||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||
if (this.methodType.equals(GET)) {
|
||||
if (this.paramMap != null) {
|
||||
String _UrlParams = getUrlParamsByMap(this.paramMap);
|
||||
this.url = this.url + "?" + _UrlParams;
|
||||
}
|
||||
|
||||
if (this.paramMap != null) {
|
||||
this.paramMap.forEach((k, v) -> {
|
||||
params.put(k, Collections.singletonList(v));
|
||||
});
|
||||
}
|
||||
} else if (this.methodType.equals(POST)) {
|
||||
if (this.paramMap != null) {
|
||||
this.paramMap.forEach((k, v) -> {
|
||||
params.put(k, Collections.singletonList(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/*** 执行Curl请求操作* @param params 请求体参数*/
|
||||
private void responseExchange(MultiValueMap<String, String> params) {
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, this.headers);
|
||||
// 执行HTTP请求,将返回的结构使用spring ResponseEntity处理http响应
|
||||
ResponseEntity<byte[]> responseEntity = this.client.exchange(this.url, this.methodType, requestEntity, byte[].class);
|
||||
String contentEncoding = responseEntity.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING);
|
||||
int httpCode = responseEntity.getStatusCodeValue();
|
||||
String httpCodeValue = responseEntity.getStatusCode().toString();
|
||||
log.info("状态码:{}", httpCodeValue);
|
||||
try {
|
||||
if ("gzip".equals(contentEncoding)) {
|
||||
// gzip解压服务器的响应体
|
||||
byte[] data = unGZip(new ByteArrayInputStream(responseEntity.getBody()));
|
||||
// log.info(new String(data, StandardCharsets.UTF_8));
|
||||
this.result = new String(data);
|
||||
} else {
|
||||
// 其他编码暂时不做处理(如果需要处理其他编码请自行扩展)
|
||||
this.result = new String(responseEntity.getBody());
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
log.error("请求错误: {}", e.getMessage());
|
||||
this.result = httpCodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
/*** 执行Curl Raw JSON请求操作* @param params 请求体参数*/
|
||||
private void responseRawExchange(String params) {
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(params, this.headers);
|
||||
// 执行HTTP请求,将返回的结构使用spring ResponseEntity处理http响应
|
||||
ResponseEntity<byte[]> responseEntity = this.client.postForEntity(this.url, requestEntity, byte[].class);
|
||||
String contentEncoding = responseEntity.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING);
|
||||
if ("gzip".equals(contentEncoding)) {
|
||||
// gzip解压服务器的响应体
|
||||
byte[] data = unGZip(new ByteArrayInputStream(responseEntity.getBody()));
|
||||
this.result = new String(data);
|
||||
} else {
|
||||
// 其他编码暂时不做处理(如果需要处理其他编码请自行扩展)
|
||||
this.result = new String(responseEntity.getBody());
|
||||
}
|
||||
}
|
||||
|
||||
/*** Gzip解压缩* @param inputStream 数据流* @return byte[]*/
|
||||
private byte[] unGZip(InputStream inputStream) {
|
||||
byte[] result = null;
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
try (GZIPInputStream gzipInputStream = new GZIPInputStream(inputStream)) {
|
||||
byte[] buf = new byte[4096];
|
||||
int len = -1;
|
||||
while ((len = gzipInputStream.read(buf, 0, buf.length)) != -1) {
|
||||
byteArrayOutputStream.write(buf, 0, len);
|
||||
}
|
||||
result = byteArrayOutputStream.toByteArray();
|
||||
} finally {
|
||||
byteArrayOutputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("unGZip error :", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*** 组装GET参数* @param params 参数* @return String*/
|
||||
private String getUrlParamsByMap(Map<String, String> params) {
|
||||
List<String> keys = new ArrayList<String>(params.keySet());
|
||||
Collections.sort(keys);
|
||||
String prestr = "";
|
||||
try {
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
String key = keys.get(i);
|
||||
String value = params.get(key);
|
||||
value = URLEncoder.encode(value, "UTF-8");
|
||||
if (i == keys.size() - 1) {
|
||||
//拼接时,不包括最后一个&字符
|
||||
prestr = prestr + key + "=" + value;
|
||||
} else {
|
||||
prestr = prestr + key + "=" + value + "&";
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error("GET params error: {}", e);
|
||||
}
|
||||
return prestr;
|
||||
}
|
||||
}
|
||||
|
||||
/*** RestTemplate 异常处理*/
|
||||
public static class RestErrorHandler implements ResponseErrorHandler {
|
||||
/*** 判断返回结果response是否是异常结果* 主要是去检查response 的HTTP Status* 仿造DefaultResponseErrorHandler实现即可*/
|
||||
@Override
|
||||
public boolean hasError(ClientHttpResponse response) throws IOException {
|
||||
int rawStatusCode = response.getRawStatusCode();
|
||||
HttpStatus statusCode = HttpStatus.resolve(rawStatusCode);
|
||||
return (statusCode != null ? statusCode.isError() : hasError(rawStatusCode));
|
||||
}
|
||||
|
||||
protected boolean hasError(int unknownStatusCode) {
|
||||
HttpStatus.Series series = HttpStatus.Series.resolve(unknownStatusCode);
|
||||
return (series == HttpStatus.Series.CLIENT_ERROR || series == HttpStatus.Series.SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleError(ClientHttpResponse response) throws IOException {
|
||||
log.error("handleError:", response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*** CurlUtil 实例化* @param builder*/
|
||||
public CurlUtil(Builder builder) {
|
||||
this.result = builder.result;
|
||||
}
|
||||
|
||||
/*** 结果* @return*/
|
||||
public String build() {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@ -4,9 +4,11 @@ import cn.org.bjca.trust.java.imserver.im.ImManager;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
@EnableJpaAuditing
|
||||
@SpringBootApplication
|
||||
@EnableAsync
|
||||
public class ImServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.org.bjca.trust.java.imserver;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class RabbitMqApiUtil {
|
||||
/*** 获取RabbitMq概况* @return*/
|
||||
public static String getRabbitMqOverView(String rabbitMqUrl, String userName, String password) {
|
||||
String url = String.format("%s/api/overview", rabbitMqUrl);
|
||||
String result = new CurlUtil.Builder(url, userName, password).addHeader("Content-Type", "application/json; charset=utf-8").get().build();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*** 获取RabbitMq vhosts* @return*/
|
||||
public static String getRabbitMqVhosts(String rabbitMqUrl, String userName, String password) {
|
||||
String url = String.format("%s/api/vhosts", rabbitMqUrl);
|
||||
return new CurlUtil.Builder(url, userName, password).addHeader("Content-Type", "application/json; charset=utf-8").get().build();
|
||||
}
|
||||
|
||||
/*** 获取RabbitMq channels* @return*/
|
||||
public static String getRabbitMqChannels(String rabbitMqUrl, String userName, String password) {
|
||||
String url = String.format("%s/api/channels", rabbitMqUrl);
|
||||
String result = new CurlUtil.Builder(url, userName, password).addHeader("Content-Type", "application/json; charset=utf-8").get().build();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*** 获取RabbitMq nodes* @return*/
|
||||
public static String getRabbitMqNodes(String rabbitMqUrl, String userName, String password) {
|
||||
String url = String.format("%s/api/nodes", rabbitMqUrl);
|
||||
String result = new CurlUtil.Builder(url, userName, password).addHeader("Content-Type", "application/json; charset=utf-8").get().build();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*** 获取RabbitMq exchanges* @return*/
|
||||
public static String getRabbitMqExchanges(String rabbitMqUrl, String userName, String password) {
|
||||
String url = String.format("%s/api/exchanges", rabbitMqUrl);
|
||||
String result = new CurlUtil.Builder(url, userName, password).addHeader("Content-Type", "application/json; charset=utf-8").get().build();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*** 获取RabbitMq queues* @param rabbitMqUrl* @param userName* @param password* @return*/
|
||||
public static String getRabbitMqQueues(String rabbitMqUrl, String userName, String password) {
|
||||
String url = String.format("%s/api/queues", rabbitMqUrl);
|
||||
String result = new CurlUtil.Builder(url, userName, password).addHeader("Content-Type", "application/json; charset=utf-8").get().build();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,15 @@
|
||||
package cn.org.bjca.trust.java.imserver.common;
|
||||
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
@Service
|
||||
public class RabbitMQHelper {
|
||||
public static void requestByGetAndParams(String requestUrl, String param) throws Exception {
|
||||
System.out.println(requestUrl + ":\n" + param);
|
||||
@ -31,4 +35,29 @@ public class RabbitMQHelper {
|
||||
bout.close();
|
||||
bout.toByteArray();
|
||||
}
|
||||
@Async("asyncExecutor")
|
||||
public void testIm(String requestUrl, String param) throws Exception {
|
||||
System.out.println(requestUrl + ":\n" + param);
|
||||
URL url = new URL(requestUrl);
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||
//设置请求方式,请求参数类型
|
||||
httpURLConnection.setRequestMethod("POST");
|
||||
httpURLConnection.setRequestProperty("content-type", "application/json;charset=UTF-8");
|
||||
httpURLConnection.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
|
||||
httpURLConnection.setDoOutput(true);
|
||||
OutputStream outputStream = httpURLConnection.getOutputStream();
|
||||
//将参数写入输出流,param必须是JSON格式
|
||||
outputStream.write(param.getBytes());
|
||||
outputStream.flush();
|
||||
InputStream inputStream = httpURLConnection.getInputStream();
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
byte[] bytes = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = inputStream.read(bytes)) >= 0) {
|
||||
bout.write(bytes, 0, len);
|
||||
}
|
||||
inputStream.close();
|
||||
bout.close();
|
||||
System.out.println(new String(bout.toByteArray()).toString());;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,31 @@
|
||||
package cn.org.bjca.trust.java.imserver.controller;
|
||||
|
||||
import cn.org.bjca.trust.java.imserver.common.RabbitMQHelper;
|
||||
import cn.org.bjca.trust.java.imserver.common.TLSSigAPIv2;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("hello")
|
||||
public class HelloController {
|
||||
private TLSSigAPIv2 tl;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public String getById(@PathVariable String id) throws Exception {
|
||||
System.out.println("id ==> " + id);
|
||||
return "{\"msg\":\"qdxorigin\",\"code\":200,\"data\":\"Sbfuiaefhaikufhcsauik\"}";
|
||||
}
|
||||
|
||||
@GetMapping("/getUserSig/{id}")
|
||||
public String getUserSig(@PathVariable String id) throws Exception {
|
||||
System.out.println("id ==> " + id);
|
||||
@ -23,4 +34,93 @@ public class HelloController {
|
||||
|
||||
return "{\"code\":0,\"data\":{\"userId\":\"" + id + "\",\"userSig\":\"" + tl.genUserSig(id, 2592000) + "\"},\"message\":\"\"}";
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/");
|
||||
|
||||
@PostMapping("/upload")
|
||||
public String upload(MultipartFile file, HttpServletRequest req) {
|
||||
|
||||
System.out.println("-------");
|
||||
System.out.println(req.toString());
|
||||
System.out.println("-------");
|
||||
if (null == file) return "{\n" +
|
||||
" \"code\": 500,\n" +
|
||||
" \"message\": \"系统异常\"\n" +
|
||||
"}";
|
||||
String realPath =
|
||||
req.getSession().getServletContext().getRealPath("/uploadFile/");
|
||||
String format = sdf.format(new Date());
|
||||
File folder = new File(realPath + format);
|
||||
String filePath = "";
|
||||
if (!folder.isDirectory()) {
|
||||
folder.mkdirs();
|
||||
String oldName = file.getOriginalFilename();
|
||||
String newName = UUID.randomUUID().toString() +
|
||||
oldName.substring(oldName.lastIndexOf("."), oldName.length());
|
||||
try {
|
||||
file.transferTo(new File(folder, newName));
|
||||
filePath = req.getScheme() + "://" + req.getServerName() + ":" +
|
||||
req.getServerPort() + "/uploadFile/" + format + newName;
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return "上传失败! ";
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
@GetMapping("/im/send")
|
||||
public String testIm() throws Exception {
|
||||
// new RabbitMQHelper().testIm("https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg?sdkappid=1400810832&identifier=administrator&usersig=eJw1jl0LgjAYRv-Lbgt9t5UuoesyNfrwosAbdUteQltzRhH990Tr8jmHA8*bpPHRUU*NRpGAzRcMAKYDfChDAsIcIONu5TXXGiUJ6AxAUBCcjQalaixecAhyWWODrTW5vZl-ilVvijM-ZO5alXHqbzooaLXKXB-C0yTh2yhM9nH3inb3uhSthuUvtVj3x6gnPMoBqP-5AjnmNEc_&random=" + 4567 + "&contenttype=json",
|
||||
// "{\"GroupId\":\"89196\",\"Random\":" + Math.abs(new Random().nextInt()) + ",\"From_Account\":\"13812345678\",\"MsgBody\":[{\"MsgType\":\"TIMTextElem\",\"MsgContent\":{\"Text\":\"red packet11111\"}}],\"CloudCustomData\":\"{\\\"doctor\\\":{\\\"name\\\":\\\"扁鹊\\\",\\\"department\\\":\\\"呼吸科\\\",\\\"avatar\\\":\\\"http://pic.imeitou.com/uploads/allimg/2018082917/11s0yqe4ggj.jpg\\\"},\\\"patient\\\":{\\\"name\\\":\\\"曹操\\\",\\\"age\\\":30,\\\"gender\\\":\\\"男\\\",\\\"avatar\\\":\\\"http://pic.imeitou.com/uploads/allimg/2018082917/o33xfvn24ct.jpg\\\"},\\\"createTime\\\":\\\"2020-12-12 12:30\\\"}\",\"SupportMessageExtension\":0,\"OfflinePushInfo\":{\"PushFlag\":0,\"title\":\"[量表填写通知]\",\"Desc\":\"医生[华佗]给您发送了一个开颅量表,请进入应用内填写。\",\"Ext\":\"{\\\"id\\\":\\\"123456\\\"}\"}}");
|
||||
createThead();
|
||||
System.out.println("-------------------------------");
|
||||
|
||||
|
||||
return "fgvhbjnkm";
|
||||
}
|
||||
|
||||
private void createThead() {
|
||||
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("demo-pool-%d").build();
|
||||
ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
|
||||
//异步执行的方法
|
||||
singleThreadPool.execute(new PatientOtherData());
|
||||
singleThreadPool.execute(new PatientOtherData());
|
||||
singleThreadPool.execute(new PatientOtherData());
|
||||
singleThreadPool.execute(new PatientOtherData());
|
||||
singleThreadPool.execute(new PatientOtherData());
|
||||
singleThreadPool.execute(new PatientOtherData());
|
||||
singleThreadPool.execute(new PatientOtherData());
|
||||
singleThreadPool.shutdown();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private class PatientOtherData implements Runnable {
|
||||
|
||||
public PatientOtherData() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
int a = Math.abs(new Random().nextInt());
|
||||
int b = Math.abs(new Random().nextInt());
|
||||
long c = (long) a + (long) b;
|
||||
try {
|
||||
new RabbitMQHelper().testIm("https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg?sdkappid=1400810832&identifier=administrator&usersig=eJw1jl0LgjAYRv-Lbgt9t5UuoesyNfrwosAbdUteQltzRhH990Tr8jmHA8*bpPHRUU*NRpGAzRcMAKYDfChDAsIcIONu5TXXGiUJ6AxAUBCcjQalaixecAhyWWODrTW5vZl-ilVvijM-ZO5alXHqbzooaLXKXB-C0yTh2yhM9nH3inb3uhSthuUvtVj3x6gnPMoBqP-5AjnmNEc_&random=" + 4567 + "&contenttype=json",
|
||||
"{\"GroupId\":\"89335\",\"Random\":" + c + ",\"From_Account\":\"13812345678\",\"MsgBody\":[{\"MsgType\":\"TIMTextElem\",\"MsgContent\":{\"Text\":\"red packet22222\"}}],\"CloudCustomData\":\"{\\\"doctor\\\":{\\\"name\\\":\\\"扁鹊\\\",\\\"department\\\":\\\"呼吸科\\\",\\\"avatar\\\":\\\"http://pic.imeitou.com/uploads/allimg/2018082917/11s0yqe4ggj.jpg\\\"},\\\"patient\\\":{\\\"name\\\":\\\"曹操\\\",\\\"age\\\":30,\\\"gender\\\":\\\"男\\\",\\\"avatar\\\":\\\"http://pic.imeitou.com/uploads/allimg/2018082917/o33xfvn24ct.jpg\\\"},\\\"createTime\\\":\\\"2020-12-12 12:30\\\"}\",\"SupportMessageExtension\":0,\"OfflinePushInfo\":{\"PushFlag\":0,\"title\":\"[量表填写通知]\",\"Desc\":\"医生[华佗]给您发送了一个开颅量表,请进入应用内填写。\",\"Ext\":\"{\\\"id\\\":\\\"123456\\\"}\"}}");
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户