PMC-930 Use the "JobsManager" class in "Derivation" class

This commit is contained in:
Roly Rudy Gutierrez Pinto
2019-07-12 18:11:09 -04:00
parent c233541f5e
commit 33b63bed20
8 changed files with 55 additions and 20 deletions

View File

@@ -17,6 +17,7 @@ require_once __DIR__ . '/../../../gulliver/system/class.g.php';
require_once __DIR__ . '/../../../bootstrap/autoload.php';
require_once __DIR__ . '/../../../bootstrap/app.php';
use ProcessMaker\Core\JobsManager;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
@@ -250,6 +251,11 @@ try {
//Processing
eprintln('Processing workspace: ' . $workspace, 'green');
/**
* JobsManager
*/
JobsManager::getSingleton()->init();
// We load plugins' pmFunctions
$oPluginRegistry = PluginRegistry::loadSingleton();

View File

@@ -4,6 +4,7 @@ use ProcessMaker\BusinessModel\EmailServer;
/*----------------------------------********---------------------------------*/
use ProcessMaker\ChangeLog\ChangeLog;
/*----------------------------------********---------------------------------*/
use ProcessMaker\Core\JobsManager;
use ProcessMaker\Core\System;
class WsBase
@@ -956,9 +957,6 @@ class WsBase
$msgError = "The default configuration wasn't defined";
}
$spool = new SpoolRun();
$spool->setConfig($setup);
$case = new Cases();
$oldFields = $case->loadCase($appUid, $delIndex);
if ($gmail == 1) {
@@ -1003,19 +1001,27 @@ class WsBase
isset($fieldsCase['PRO_ID']) ? $fieldsCase['PRO_ID'] : 0,
$this->getTaskId() ?$this->getTaskId():(isset($oldFields['TAS_ID'])? $oldFields['TAS_ID'] : 0)
);
$spool->create($messageArray);
$result = "";
if ($gmail != 1) {
$spool->sendMail();
if ($spool->status == 'sent') {
$result = new WsResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to);
} else {
$result = new WsResponse(29, $spool->status . ' ' . $spool->error . print_r($setup, 1));
$closure = function() use ($setup, $messageArray, $gmail, $to) {
$spool = new SpoolRun();
$spool->setConfig($setup);
$spool->create($messageArray);
$spool->sendMail();
return $spool;
};
$result = new WsResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to);
switch ($appMsgType) {
case WsBase::MESSAGE_TYPE_EMAIL_EVENT:
case WsBase::MESSAGE_TYPE_PM_FUNCTION:
JobsManager::getSingleton()->dispatch('EmailEvent', $closure);
break;
default :
JobsManager::getSingleton()->dispatch('Email', $closure);
break;
}
}
return $result;
} catch (Exception $e) {
return new WsResponse(100, $e->getMessage());

6
workflow/engine/config/schema.xml Normal file → Executable file
View File

@@ -5837,9 +5837,9 @@
<column name="queue" type="VARCHAR" size="255" required="true"/>
<column name="payload" type="LONGVARCHAR" required="true"/>
<column name="attempts" type="TINYINT" size="3" required="true"/>
<column name="reserved_at" type="TINYINT" size="10" required="false"/>
<column name="available_at" type="TINYINT" size="10" required="true"/>
<column name="created_at" type="TINYINT" size="10" required="true"/>
<column name="reserved_at" type="BIGINT" size="10" required="false"/>
<column name="available_at" type="BIGINT" size="10" required="true"/>
<column name="created_at" type="BIGINT" size="10" required="true"/>
<index name="jobs_queue_index">
<index-column name="queue"/>
</index>

View File

@@ -3257,9 +3257,9 @@ CREATE TABLE `JOBS_PENDING`
`queue` VARCHAR(255) NOT NULL,
`payload` MEDIUMTEXT NOT NULL,
`attempts` TINYINT(3) NOT NULL,
`reserved_at` TINYINT(10),
`available_at` TINYINT(10) NOT NULL,
`created_at` TINYINT(10) NOT NULL,
`reserved_at` BIGINT(10),
`available_at` BIGINT(10) NOT NULL,
`created_at` BIGINT(10) NOT NULL,
PRIMARY KEY (`id`),
KEY `jobs_queue_index`(`queue`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8';

View File

@@ -30,7 +30,7 @@ class System
private static $config = null;
private static $debug = null;
private static $instance;
private static $defaultConfig = array(
private static $defaultConfig = [
'debug' => 0,
'debug_sql' => 0,
'debug_time' => 0,
@@ -70,8 +70,11 @@ class System
'google_map_signature' => '',
'logging_level' => 'INFO',
'upload_attempts_limit_per_user' => '60,1',
'files_white_list' => ''
);
'files_white_list' => '',
'delay' => '0',
'tries' => '10',
'retry_after' => '90'
];
/**
* List currently installed plugins

View File

@@ -2,6 +2,7 @@
use Illuminate\Foundation\Http\Kernel;
use ProcessMaker\Core\AppEvent;
use ProcessMaker\Core\JobsManager;
/*----------------------------------********---------------------------------*/
use ProcessMaker\ChangeLog\ChangeLog;
/*----------------------------------********---------------------------------*/
@@ -704,6 +705,11 @@ if (defined('DEBUG_SQL_LOG') && DEBUG_SQL_LOG) {
Propel::init(PATH_CORE . "config/databases.php");
}
/**
* JobsManager
*/
JobsManager::getSingleton()->init();
//here we are loading all plugins registered
//the singleton has a list of enabled plugins
$oPluginRegistry = PluginRegistry::loadSingleton();