From d98fd1046a48f90b0448b04adaf4c68c99f54fbf Mon Sep 17 00:00:00 2001 From: Mikhail Chechnev Date: Wed, 14 Nov 2018 10:05:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BD=D0=B0=D0=B8=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=B4=D1=83=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B2=20=D1=81=D0=B5=D1=81=D1=81=D0=B8=D0=B8=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BA=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.js | 4 +++- core/db_connector.js | 3 ++- index.js | 16 +++++++++------- modules/parus_oracle_db.js | 6 ++++-- 4 files changed, 18 insertions(+), 11 deletions(-) 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 } } },