Commit 280bf159 by 宋毅

tj

parent 5a2c0822
...@@ -16,6 +16,7 @@ class APIBase { ...@@ -16,6 +16,7 @@ class APIBase {
if (!pobj.actionBody) { if (!pobj.actionBody) {
pobj.actionBody = {}; pobj.actionBody = {};
} }
pobj.actionBody.requestId = pobj.requestId ? pobj.requestId : pobj.actionBody.requestId || await this.getBusUid("mq-");
var shaStr = await sha256(JSON.stringify(pobj)); var shaStr = await sha256(JSON.stringify(pobj));
this.redisClient.setWithEx(shaStr, 1, 3); this.redisClient.setWithEx(shaStr, 1, 3);
var result = await this[methodname](pobj, query, req); var result = await this[methodname](pobj, query, req);
...@@ -23,13 +24,13 @@ class APIBase { ...@@ -23,13 +24,13 @@ class APIBase {
result = system.getResult(null, "请求的方法返回值为空"); result = system.getResult(null, "请求的方法返回值为空");
} }
if (!result.requestId) { if (!result.requestId) {
result.requestId = pobj.actionBody.requestId || await this.getBusUid("scz"); result.requestId = pobj.actionBody.requestId;
} }
if ("LOGS-SYTXPUBLIC-MSGQ" != settings.queuedName) { if ("LOGS-SYTXPUBLIC-MSGQ" != settings.queuedName) {
pobj.actionBody.resultInfo = result; pobj.actionBody.resultInfo = result;
pobj.actionBody.requestId = result.requestId; pobj.actionBody.requestId = result.requestId;
pobj.actionBody.opTitle = "reqPath:" + req.path; pobj.actionBody.opTitle = "reqPath:" + req.path;
this.esUtils.addEsLogs(settings.queuedName + "api-req", pobj); this.esUtils.addEsLogs(settings.queuedName + "-apireq", pobj.actionBody);
} }
return result; return result;
} catch (error) { } catch (error) {
...@@ -38,8 +39,8 @@ class APIBase { ...@@ -38,8 +39,8 @@ class APIBase {
var rtnerror = system.getResultFail(-200, "出现异常,error:" + stackStr); var rtnerror = system.getResultFail(-200, "出现异常,error:" + stackStr);
pobj.actionBody.requestId = pobj.actionBody.requestId || await this.getBusUid("err"); pobj.actionBody.requestId = pobj.actionBody.requestId || await this.getBusUid("err");
pobj.actionBody.errorInfo = stackStr; pobj.actionBody.errorInfo = stackStr;
pobj.actionBody.opTitle = ",reqPath:" + req.path; pobj.actionBody.opTitle = "请求出现异常,reqPath:" + req.path;
this.esUtils.addEsLogs(settings.queuedName + "apidoexec-error", pobj); this.esUtils.addEsLogs(settings.queuedName + "-apireq", pobj.actionBody);
return rtnerror; return rtnerror;
} }
} }
......
...@@ -24,6 +24,9 @@ class ProducerAPI extends APIBase { ...@@ -24,6 +24,9 @@ class ProducerAPI extends APIBase {
var opResult = null; var opResult = null;
switch (actionType) { switch (actionType) {
case "produceData": case "produceData":
if (settings.queuedName != "SYTXPUBLIC-MSGQ") {
return system.getResult(null, "请求地址有误!");
}
opResult = await this.utilsProduceSve.produceData(pobj, req); opResult = await this.utilsProduceSve.produceData(pobj, req);
break; break;
case "produceLogsData": case "produceLogsData":
......
...@@ -17,8 +17,7 @@ class PublicConsumer extends ConsumerBase { ...@@ -17,8 +17,7 @@ class PublicConsumer extends ConsumerBase {
requestId: actionBody.requestId requestId: actionBody.requestId
} }
console.log(JSON.stringify(params), "publicConsumer-->subDoConsumer...pushurl=" + actionBody.pushUrl); console.log(JSON.stringify(params), "publicConsumer-->subDoConsumer...pushurl=" + actionBody.pushUrl);
var execResult = await this.execPostByTimeOut(params, actionBody.pushUrl); var execResult = await this.execPostByTimeOut(params, actionBody.pushUrl, null, null, 5);
console.log(JSON.stringify(execResult), "publicConsumer-->subDoConsumer.....结果......pushurl=" + actionBody.pushUrl);
var tmpBody = { var tmpBody = {
"opTitle": "队列推送数据记录,推送地址:" + actionBody.pushUrl,// N 操作的业务标题 "opTitle": "队列推送数据记录,推送地址:" + actionBody.pushUrl,// N 操作的业务标题
"identifyCode": actionBody.identifyCode || "",// Y 操作的业务标识 "identifyCode": actionBody.identifyCode || "",// Y 操作的业务标识
......
...@@ -26,8 +26,12 @@ class EsUtils { ...@@ -26,8 +26,12 @@ class EsUtils {
actionBody.messageBody = actionBody.messageBody + ";actionType=" + (actionBody.actionType || "") + ";pushUrl=" + (actionBody.pushUrl || ""); actionBody.messageBody = actionBody.messageBody + ";actionType=" + (actionBody.actionType || "") + ";pushUrl=" + (actionBody.pushUrl || "");
} }
if (typeof actionBody.messageBody === 'object') { if (typeof actionBody.messageBody === 'object') {
actionBody.messageBody.actionType = actionBody.actionType || ""; if (!actionBody.messageBody.actionType) {
actionBody.messageBody.pushUrl = actionBody.pushUrl || ""; actionBody.messageBody.actionType = actionBody.actionType || "";
}
if (!actionBody.messageBody.pushUrl) {
actionBody.messageBody.pushUrl = actionBody.pushUrl || "";
}
} }
actionBody.messageBody = typeof actionBody.messageBody === 'object' ? JSON.stringify(actionBody.messageBody) : actionBody.messageBody || ""; actionBody.messageBody = typeof actionBody.messageBody === 'object' ? JSON.stringify(actionBody.messageBody) : actionBody.messageBody || "";
var params = { var params = {
...@@ -92,7 +96,7 @@ class EsUtils { ...@@ -92,7 +96,7 @@ class EsUtils {
return system.getResult(null, "execPostTimeOut data is empty"); return system.getResult(null, "execPostTimeOut data is empty");
} }
var stdoutInfo = JSON.parse(result.stdout); var stdoutInfo = JSON.parse(result.stdout);
if(stdoutInfo.error && stdoutInfo.error.reason==="no such index"){ if (stdoutInfo.error && stdoutInfo.error.reason === "no such index") {
return system.getResult(null, "no such index info"); return system.getResult(null, "no such index info");
} }
if (stdoutInfo.error) { if (stdoutInfo.error) {
......
...@@ -10,8 +10,8 @@ var ENVINPUT = { ...@@ -10,8 +10,8 @@ var ENVINPUT = {
REDIS_DB: process.env.QUEUE_REDIS_DB, REDIS_DB: process.env.QUEUE_REDIS_DB,
DB_NAME: process.env.QUEUE_DB_NAME, DB_NAME: process.env.QUEUE_DB_NAME,
APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "test",//运行环境 APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "test",//运行环境
CONSUMER_NAME: process.env.CONSUMER_NAME || "publicLogs.publicLogsConsumer",//消费者名称 CONSUMER_NAME: process.env.CONSUMER_NAME || "publicServiceAllocation.publicConsumer",//消费者名称
QUEUED_NAME: process.env.QUEUED_NAME || "LOGS-SYTXPUBLIC-MSGQ",//队列名称,FAIL-失败队列(队列和失败队列一对存在进行部署) QUEUED_NAME: process.env.QUEUED_NAME || "SYTXPUBLIC-MSGQ",//队列名称,FAIL-失败队列(队列和失败队列一对存在进行部署)
}; };
var settings = { var settings = {
env: ENVINPUT.APP_ENV, env: ENVINPUT.APP_ENV,
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
"name":"张三", "name":"张三",
"age":21 "age":21
} }
} },
"requestId":"PUB-202006111530vbot" // N 请求id
} }
1.(1) 推送地址:http://60.205.209.94:4012/web/auth/channelAccessAuth/springBoard 1.(1) 推送地址:http://60.205.209.94:4012/web/auth/channelAccessAuth/springBoard
参数: 参数:
...@@ -42,7 +43,7 @@ ...@@ -42,7 +43,7 @@
"name":"张三", "name":"张三",
"age":21 "age":21
}, },
"requestId":"PUB-202006111530vbot" "requestId":"PUB-202006111530vbot" // N 请求id
} }
返回参数: 返回参数:
{ {
...@@ -66,7 +67,7 @@ ...@@ -66,7 +67,7 @@
data: null//业务处理返回 data: null//业务处理返回
} }
}, },
"requestId":"PUB-202006111530vbot" "requestId":"PUB-202006111530vbot" // N 请求id
} }
返回参数: 返回参数:
{ {
...@@ -91,7 +92,8 @@ ...@@ -91,7 +92,8 @@
}, },
"resultInfo":"",//返回信息 "resultInfo":"",//返回信息
"errorInfo": ""//错误信息 "errorInfo": ""//错误信息
} },
"requestId":"PUB-202006111530vbot" // N 请求id
} }
返回参数: 返回参数:
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment