forked from CITKParus/P8-ExchangeService
Поддержка пула подключений к СУБД Oracle
This commit is contained in:
parent
f13de84d26
commit
ad719c678f
@ -9,6 +9,12 @@
|
|||||||
|
|
||||||
const oracledb = require("oracledb"); //Работа с СУБД Oracle
|
const oracledb = require("oracledb"); //Работа с СУБД Oracle
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Глобальные идентификаторы
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
const NPOOL_DRAIN_TIME = 30; //Таймаут ожидания завершения подключений при отключении пула от БД (сек)
|
||||||
|
|
||||||
//------------
|
//------------
|
||||||
// Тело модуля
|
// Тело модуля
|
||||||
//------------
|
//------------
|
||||||
@ -33,14 +39,23 @@ const readCursorData = cursor => {
|
|||||||
//Подключение к БД
|
//Подключение к БД
|
||||||
const connect = async prms => {
|
const connect = async prms => {
|
||||||
try {
|
try {
|
||||||
const conn = await oracledb.getConnection({
|
let pool = await oracledb.createPool({
|
||||||
user: prms.sUser,
|
user: prms.sUser,
|
||||||
password: prms.sPassword,
|
password: prms.sPassword,
|
||||||
connectString: prms.sConnectString
|
connectString: prms.sConnectString,
|
||||||
|
sessionCallback: (connection, requestedTag, callback) => {
|
||||||
|
if (prms.sSessionAppName) connection.module = prms.sSessionAppName;
|
||||||
|
connection.execute(`ALTER SESSION SET CURRENT_SCHEMA=${prms.sSchema}`).then(
|
||||||
|
r => {
|
||||||
|
callback(null, connection);
|
||||||
|
},
|
||||||
|
e => {
|
||||||
|
callback(e, null);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (prms.sSessionAppName) conn.module = prms.sSessionAppName;
|
return pool;
|
||||||
await conn.execute(`ALTER SESSION SET CURRENT_SCHEMA=${prms.sSchema}`);
|
|
||||||
return conn;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
}
|
}
|
||||||
@ -49,7 +64,7 @@ const connect = async prms => {
|
|||||||
//Отключение от БД
|
//Отключение от БД
|
||||||
const disconnect = async prms => {
|
const disconnect = async prms => {
|
||||||
try {
|
try {
|
||||||
await prms.connection.close();
|
await prms.connection.close(NPOOL_DRAIN_TIME);
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
@ -58,8 +73,10 @@ const disconnect = async prms => {
|
|||||||
|
|
||||||
//Получение списка сервисов
|
//Получение списка сервисов
|
||||||
const getServices = async prms => {
|
const getServices = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.SERVICES_GET(RCSERVICES => :RCSERVICES); END;",
|
"BEGIN PKG_EXS.SERVICES_GET(RCSERVICES => :RCSERVICES); END;",
|
||||||
{ RCSERVICES: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } },
|
{ RCSERVICES: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } },
|
||||||
{ outFormat: oracledb.OBJECT }
|
{ outFormat: oracledb.OBJECT }
|
||||||
@ -68,13 +85,23 @@ const getServices = async prms => {
|
|||||||
return rows;
|
return rows;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Получение списка функций сервиса
|
//Получение списка функций сервиса
|
||||||
const getServiceFunctions = async prms => {
|
const getServiceFunctions = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.SERVICEFNS_GET(NEXSSERVICE => :NEXSSERVICE, RCSERVICEFNS => :RCSERVICEFNS); END;",
|
"BEGIN PKG_EXS.SERVICEFNS_GET(NEXSSERVICE => :NEXSSERVICE, RCSERVICEFNS => :RCSERVICEFNS); END;",
|
||||||
{ NEXSSERVICE: prms.nServiceId, RCSERVICEFNS: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } },
|
{ NEXSSERVICE: prms.nServiceId, RCSERVICEFNS: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } },
|
||||||
{ outFormat: oracledb.OBJECT }
|
{ outFormat: oracledb.OBJECT }
|
||||||
@ -83,13 +110,23 @@ const getServiceFunctions = async prms => {
|
|||||||
return rows;
|
return rows;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Получение контекста сервиса
|
//Получение контекста сервиса
|
||||||
const getServiceContext = async prms => {
|
const getServiceContext = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.SERVICE_CTX_GET(NFLAG_SMART => 0, NEXSSERVICE => :NEXSSERVICE, RCSERVICE_CTX => :RCSERVICE_CTX); END;",
|
"BEGIN PKG_EXS.SERVICE_CTX_GET(NFLAG_SMART => 0, NEXSSERVICE => :NEXSSERVICE, RCSERVICE_CTX => :RCSERVICE_CTX); END;",
|
||||||
{ NEXSSERVICE: prms.nServiceId, RCSERVICE_CTX: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } },
|
{ NEXSSERVICE: prms.nServiceId, RCSERVICE_CTX: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } },
|
||||||
{ outFormat: oracledb.OBJECT }
|
{ outFormat: oracledb.OBJECT }
|
||||||
@ -98,65 +135,115 @@ const getServiceContext = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Установка контекста сервиса
|
//Установка контекста сервиса
|
||||||
const setServiceContext = async prms => {
|
const setServiceContext = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.SERVICE_CTX_SET(NEXSSERVICE => :NEXSSERVICE, SCTX => :SCTX, DCTX_EXP => :DCTX_EXP); END;",
|
"BEGIN PKG_EXS.SERVICE_CTX_SET(NEXSSERVICE => :NEXSSERVICE, SCTX => :SCTX, DCTX_EXP => :DCTX_EXP); END;",
|
||||||
{ NEXSSERVICE: prms.nServiceId, SCTX: prms.sCtx, DCTX_EXP: prms.dCtxExp },
|
{ NEXSSERVICE: prms.nServiceId, SCTX: prms.sCtx, DCTX_EXP: prms.dCtxExp },
|
||||||
{ autoCommit: true }
|
{ autoCommit: true }
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Очистка контекста сервиса
|
//Очистка контекста сервиса
|
||||||
const clearServiceContext = async prms => {
|
const clearServiceContext = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.SERVICE_CTX_CLEAR(NEXSSERVICE => :NEXSSERVICE); END;",
|
"BEGIN PKG_EXS.SERVICE_CTX_CLEAR(NEXSSERVICE => :NEXSSERVICE); END;",
|
||||||
{ NEXSSERVICE: prms.nServiceId },
|
{ NEXSSERVICE: prms.nServiceId },
|
||||||
{ autoCommit: true }
|
{ autoCommit: true }
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Проверка атуентифицированности сервиса
|
//Проверка атуентифицированности сервиса
|
||||||
const isServiceAuth = async prms => {
|
const isServiceAuth = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN :RET := PKG_EXS.SERVICE_IS_AUTH(NEXSSERVICE => :NEXSSERVICE); END;",
|
"BEGIN :RET := PKG_EXS.SERVICE_IS_AUTH(NEXSSERVICE => :NEXSSERVICE); END;",
|
||||||
{ NEXSSERVICE: prms.nServiceId, RET: { dir: oracledb.BIND_OUT, type: oracledb.NUMBER } }
|
{ NEXSSERVICE: prms.nServiceId, RET: { dir: oracledb.BIND_OUT, type: oracledb.NUMBER } }
|
||||||
);
|
);
|
||||||
return res.outBinds.RET;
|
return res.outBinds.RET;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Постановка в очередь задания на аутентификацию сервиса
|
//Постановка в очередь задания на аутентификацию сервиса
|
||||||
const putServiceAuthInQueue = async prms => {
|
const putServiceAuthInQueue = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.SERVICE_AUTH_PUT_INQUEUE(NEXSSERVICE => :NEXSSERVICE, NFORCE => :NFORCE); END;",
|
"BEGIN PKG_EXS.SERVICE_AUTH_PUT_INQUEUE(NEXSSERVICE => :NEXSSERVICE, NFORCE => :NFORCE); END;",
|
||||||
{ NEXSSERVICE: prms.nServiceId, NFORCE: prms.nForce },
|
{ NEXSSERVICE: prms.nServiceId, NFORCE: prms.nForce },
|
||||||
{ autoCommit: true }
|
{ autoCommit: true }
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Получение информации о просроченных сообщениях обмена сервиса
|
//Получение информации о просроченных сообщениях обмена сервиса
|
||||||
const getServiceExpiredQueueInfo = async prms => {
|
const getServiceExpiredQueueInfo = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.SERVICE_QUEUE_EXPIRED_INFO_GET(NEXSSERVICE => :NEXSSERVICE, RCSERVICE_QUEUE_EXPIRED_INFO => :RCSERVICE_QUEUE_EXPIRED_INFO); END;",
|
"BEGIN PKG_EXS.SERVICE_QUEUE_EXPIRED_INFO_GET(NEXSSERVICE => :NEXSSERVICE, RCSERVICE_QUEUE_EXPIRED_INFO => :RCSERVICE_QUEUE_EXPIRED_INFO); END;",
|
||||||
{
|
{
|
||||||
NEXSSERVICE: prms.nServiceId,
|
NEXSSERVICE: prms.nServiceId,
|
||||||
@ -168,13 +255,23 @@ const getServiceExpiredQueueInfo = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Запись в протокол работы
|
//Запись в протокол работы
|
||||||
const log = async prms => {
|
const log = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.LOG_PUT(NLOG_STATE => :NLOG_STATE, SMSG => :SMSG, NEXSSERVICE => :NEXSSERVICE, NEXSSERVICEFN => :NEXSSERVICEFN, NEXSQUEUE => :NEXSQUEUE, RCLOG => :RCLOG); END;",
|
"BEGIN PKG_EXS.LOG_PUT(NLOG_STATE => :NLOG_STATE, SMSG => :SMSG, NEXSSERVICE => :NEXSSERVICE, NEXSSERVICEFN => :NEXSSERVICEFN, NEXSQUEUE => :NEXSQUEUE, RCLOG => :RCLOG); END;",
|
||||||
{
|
{
|
||||||
NLOG_STATE: prms.nLogState,
|
NLOG_STATE: prms.nLogState,
|
||||||
@ -190,13 +287,23 @@ const log = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Считывание записи очереди обмена
|
//Считывание записи очереди обмена
|
||||||
const getQueue = async prms => {
|
const getQueue = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_GET(NFLAG_SMART => 0, NEXSQUEUE => :NEXSQUEUE, RCQUEUE => :RCQUEUE); END;",
|
"BEGIN PKG_EXS.QUEUE_GET(NFLAG_SMART => 0, NEXSQUEUE => :NEXSQUEUE, RCQUEUE => :RCQUEUE); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -208,13 +315,23 @@ const getQueue = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Помещение сообщения в очередь
|
//Помещение сообщения в очередь
|
||||||
const putQueue = async prms => {
|
const putQueue = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_PUT(NEXSSERVICEFN => :NEXSSERVICEFN, BMSG => :BMSG, NEXSQUEUE => :NEXSQUEUE, NLNK_COMPANY => :NLNK_COMPANY, NLNK_DOCUMENT => :NLNK_DOCUMENT, SLNK_UNITCODE => :SLNK_UNITCODE, SOPTIONS => :SOPTIONS, RCQUEUE => :RCQUEUE); END;",
|
"BEGIN PKG_EXS.QUEUE_PUT(NEXSSERVICEFN => :NEXSSERVICEFN, BMSG => :BMSG, NEXSQUEUE => :NEXSQUEUE, NLNK_COMPANY => :NLNK_COMPANY, NLNK_DOCUMENT => :NLNK_DOCUMENT, SLNK_UNITCODE => :SLNK_UNITCODE, SOPTIONS => :SOPTIONS, RCQUEUE => :RCQUEUE); END;",
|
||||||
{
|
{
|
||||||
NEXSSERVICEFN: prms.nServiceFnId,
|
NEXSSERVICEFN: prms.nServiceFnId,
|
||||||
@ -232,13 +349,23 @@ const putQueue = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Считывание очередной порции исходящих сообщений из очереди
|
//Считывание очередной порции исходящих сообщений из очереди
|
||||||
const getQueueOutgoing = async prms => {
|
const getQueueOutgoing = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_SRV_TYPE_SEND_GET(NPORTION_SIZE => :NPORTION_SIZE, RCQUEUES => :RCQUEUES); END;",
|
"BEGIN PKG_EXS.QUEUE_SRV_TYPE_SEND_GET(NPORTION_SIZE => :NPORTION_SIZE, RCQUEUES => :RCQUEUES); END;",
|
||||||
{
|
{
|
||||||
NPORTION_SIZE: prms.nPortionSize,
|
NPORTION_SIZE: prms.nPortionSize,
|
||||||
@ -250,13 +377,23 @@ const getQueueOutgoing = async prms => {
|
|||||||
return rows;
|
return rows;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Установка значения состояния в сообщении очереди
|
//Установка значения состояния в сообщении очереди
|
||||||
const setQueueState = async prms => {
|
const setQueueState = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_EXEC_STATE_SET(NEXSQUEUE => :NEXSQUEUE, NEXEC_STATE => :NEXEC_STATE, SEXEC_MSG => :SEXEC_MSG, NINC_EXEC_CNT => :NINC_EXEC_CNT, NRESET_DATA => :NRESET_DATA, RCQUEUE => :RCQUEUE); END;",
|
"BEGIN PKG_EXS.QUEUE_EXEC_STATE_SET(NEXSQUEUE => :NEXSQUEUE, NEXEC_STATE => :NEXEC_STATE, SEXEC_MSG => :SEXEC_MSG, NINC_EXEC_CNT => :NINC_EXEC_CNT, NRESET_DATA => :NRESET_DATA, RCQUEUE => :RCQUEUE); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -272,13 +409,23 @@ const setQueueState = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Считывание данных сообщения очереди
|
//Считывание данных сообщения очереди
|
||||||
const getQueueMsg = async prms => {
|
const getQueueMsg = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_MSG_GET(NEXSQUEUE => :NEXSQUEUE, RCQUEUE_MSG => :RCQUEUE_MSG); END;",
|
"BEGIN PKG_EXS.QUEUE_MSG_GET(NEXSQUEUE => :NEXSQUEUE, RCQUEUE_MSG => :RCQUEUE_MSG); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -294,13 +441,23 @@ const getQueueMsg = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Установка данных сообщения очереди
|
//Установка данных сообщения очереди
|
||||||
const setQueueMsg = async prms => {
|
const setQueueMsg = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_MSG_SET(NEXSQUEUE => :NEXSQUEUE, BMSG => :BMSG, RCQUEUE => :RCQUEUE); END;",
|
"BEGIN PKG_EXS.QUEUE_MSG_SET(NEXSQUEUE => :NEXSQUEUE, BMSG => :BMSG, RCQUEUE => :RCQUEUE); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -313,13 +470,23 @@ const setQueueMsg = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Установка параметров сообщения очереди
|
//Установка параметров сообщения очереди
|
||||||
const setQueueOptions = async prms => {
|
const setQueueOptions = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_OPTIONS_SET(NEXSQUEUE => :NEXSQUEUE, SOPTIONS => :SOPTIONS, RCQUEUE => :RCQUEUE); END;",
|
"BEGIN PKG_EXS.QUEUE_OPTIONS_SET(NEXSQUEUE => :NEXSQUEUE, SOPTIONS => :SOPTIONS, RCQUEUE => :RCQUEUE); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -332,13 +499,23 @@ const setQueueOptions = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Считывание результата обработки сообщения очереди
|
//Считывание результата обработки сообщения очереди
|
||||||
const getQueueResp = async prms => {
|
const getQueueResp = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_RESP_GET(NEXSQUEUE => :NEXSQUEUE, RCQUEUE_RESP => :RCQUEUE_RESP); END;",
|
"BEGIN PKG_EXS.QUEUE_RESP_GET(NEXSQUEUE => :NEXSQUEUE, RCQUEUE_RESP => :RCQUEUE_RESP); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -354,13 +531,23 @@ const getQueueResp = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Установка результата обработки сообщения очереди
|
//Установка результата обработки сообщения очереди
|
||||||
const setQueueResp = async prms => {
|
const setQueueResp = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_RESP_SET(NEXSQUEUE => :NEXSQUEUE, BRESP => :BRESP, NIS_ORIGINAL => :NIS_ORIGINAL, RCQUEUE => :RCQUEUE); END;",
|
"BEGIN PKG_EXS.QUEUE_RESP_SET(NEXSQUEUE => :NEXSQUEUE, BRESP => :BRESP, NIS_ORIGINAL => :NIS_ORIGINAL, RCQUEUE => :RCQUEUE); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -374,13 +561,23 @@ const setQueueResp = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Установка параметров результата обработки сообщения очереди
|
//Установка параметров результата обработки сообщения очереди
|
||||||
const setQueueOptionsResp = async prms => {
|
const setQueueOptionsResp = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_OPTIONS_RESP_SET(NEXSQUEUE => :NEXSQUEUE, SOPTIONS_RESP => :SOPTIONS_RESP, RCQUEUE => :RCQUEUE); END;",
|
"BEGIN PKG_EXS.QUEUE_OPTIONS_RESP_SET(NEXSQUEUE => :NEXSQUEUE, SOPTIONS_RESP => :SOPTIONS_RESP, RCQUEUE => :RCQUEUE); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -393,13 +590,23 @@ const setQueueOptionsResp = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Исполнение обработчика со стороны БД для сообщения очереди
|
//Исполнение обработчика со стороны БД для сообщения очереди
|
||||||
const execQueuePrc = async prms => {
|
const execQueuePrc = async prms => {
|
||||||
|
let pooledConnection;
|
||||||
try {
|
try {
|
||||||
let res = await prms.connection.execute(
|
pooledConnection = await prms.connection.getConnection();
|
||||||
|
let res = await pooledConnection.execute(
|
||||||
"BEGIN PKG_EXS.QUEUE_PRC(NEXSQUEUE => :NEXSQUEUE, RCRESULT => :RCRESULT); END;",
|
"BEGIN PKG_EXS.QUEUE_PRC(NEXSQUEUE => :NEXSQUEUE, RCRESULT => :RCRESULT); END;",
|
||||||
{
|
{
|
||||||
NEXSQUEUE: prms.nQueueId,
|
NEXSQUEUE: prms.nQueueId,
|
||||||
@ -411,6 +618,14 @@ const execQueuePrc = async prms => {
|
|||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e.message);
|
throw new Error(e.message);
|
||||||
|
} finally {
|
||||||
|
if (pooledConnection) {
|
||||||
|
try {
|
||||||
|
await pooledConnection.close();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user