diff --git a/config.js b/config.js index aeb8aef..523f365 100644 --- a/config.js +++ b/config.js @@ -15,7 +15,9 @@ let dbConnect = { password: "parus", //Строка подключения к БД connectString: "DEMOP_CITKSERV_WAN", - //Модуль обслуживания БД + //Наименование модуля (для сессии БД) + moduleName: "PARUS$ExchangeServer", + //Подключаемый модуль обслуживания БД (низкоуровневые функции работы с СУБД) module: "parus_oracle_db.js" }; diff --git a/core/db_connector.js b/core/db_connector.js index fee61cf..0e2e14a 100644 --- a/core/db_connector.js +++ b/core/db_connector.js @@ -87,7 +87,8 @@ class DBConnector { this.connection = await this.connector.connect( this.connectSettings.user, this.connectSettings.password, - this.connectSettings.connectString + this.connectSettings.connectString, + this.connectSettings.moduleName ); return this.connection; } catch (e) { diff --git a/index.js b/index.js index 065c1e4..43e89fa 100644 --- a/index.js +++ b/index.js @@ -35,13 +35,15 @@ try { a.putLog(db.MSG_TYPE_INF, "Сервер приложений подключен") .then(res => { console.log(res); - a.disconnect() - .then(res => { - console.log("DISCONNECTED"); - }) - .catch(e => { - console.log(e.code + ": " + e.message); - }); + setTimeout(() => { + a.disconnect() + .then(res => { + console.log("DISCONNECTED"); + }) + .catch(e => { + console.log(e.code + ": " + e.message); + }); + }, 10000); }) .catch(e => { console.log(e.code + ": " + e.message); diff --git a/modules/parus_oracle_db.js b/modules/parus_oracle_db.js index 327dfad..6192eab 100644 --- a/modules/parus_oracle_db.js +++ b/modules/parus_oracle_db.js @@ -38,13 +38,14 @@ const SLOG_STATE_ERR = "ERR"; //Ошибка (строковый код) //------------ //Подключение к БД -const connect = async (user, password, connectString) => { +const connect = async (user, password, connectString, moduleName) => { try { const conn = await oracledb.getConnection({ user, password, connectString }); + conn.module = moduleName; return conn; } catch (e) { throw new Error(e.message); @@ -174,9 +175,10 @@ const getQueueOutgoing = (connection, portionSize) => { return new Promise((resolve, reject) => { if (connection) { connection.execute( - "BEGIN PKG_EXS.QUEUE_OUT_GET(NPORTION => :NPORTION, RCQUEUES => :RCQUEUES); END;", + "BEGIN PKG_EXS.QUEUE_GET(NPORTION => :NPORTION, NSRV_TYPE => :NSRV_TYPE, RCQUEUES => :RCQUEUES); END;", { NPORTION: portionSize, + NSRV_TYPE: NSRV_TYPE_SEND, RCQUEUES: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, { outFormat: oracledb.OBJECT, autoCommit: true, fetchInfo: { BMSG: { type: oracledb.BUFFER } } },