Unverified Commit a22db088 authored by Jerome Boucher's avatar Jerome Boucher
Browse files

fix/#12115 : avoid parallel processing in medona

parent 37410315
......@@ -399,11 +399,18 @@ class ArchiveDeliveryRequest extends abstractMessage
{
$results = array();
$messages = $this->sdoFactory->find(
$messageIds = $this->sdoFactory->index(
"medona/message",
["messageId"],
"status='accepted' AND type='ArchiveDeliveryRequest' AND active=true"
);
foreach ($messages as $message) {
foreach ($messageIds as $messageId) {
// Avoid parallel processing
$message = $this->sdoFactory->read('medona/message', (string) $messageId);
if (!$message->status != 'accepted') {
continue;
}
$this->changeStatus($message->messageId, "processing");
$this->readOrgs($message);
......
......@@ -308,9 +308,9 @@ class ArchiveDestructionRequest extends abstractMessage
{
$results = array();
$index = $this->sdoFactory->index(
$messageIds = $this->sdoFactory->index(
'medona/message',
array('messageId'),
['messageId'],
'(
type = "ArchiveDestructionRequest"
OR type = "ArchiveRestitution"
......@@ -322,7 +322,14 @@ class ArchiveDestructionRequest extends abstractMessage
AND status = "validated"'
);
foreach ($index as $messageId) {
foreach ($messageIds as $messageId) {
// Avoid parallel processing
$message = $this->sdoFactory->read('medona/message', (string) $messageId);
if (!$message->status != 'validated') {
continue;
}
$this->changeStatus($message->messageId, "processing");
$results[(string) $messageId] = $this->process($messageId);
}
......
......@@ -366,12 +366,20 @@ class ArchiveRestitutionRequest extends abstractMessage
{
$results = array();
$messages = $this->sdoFactory->find(
$messageIds = $this->sdoFactory->index(
"medona/message",
["messageId"],
"status='accepted' AND type='ArchiveRestitutionRequest' AND active=true"
);
foreach ($messages as $message) {
foreach ($messageIds as $messageId) {
// Avoid parallel processing
$message = $this->sdoFactory->read('medona/message', (string) $messageId);
if (!$message->status != 'accepted') {
continue;
}
$this->changeStatus($message->messageId, "processing");
try {
$results[(string) $message->messageId] = $this->process((string)$message->messageId);
} catch (\Exception $e) {
......@@ -432,8 +440,7 @@ class ArchiveRestitutionRequest extends abstractMessage
$operationResult
);
$message->status = "processed";
$this->update($message);
$this->changeStatus($message->messageId, "processed");
return true;
}
......
......@@ -377,10 +377,20 @@ class ArchiveTransfer extends abstractMessage
*/
public function validateBatch()
{
$results = array();
$results = [];
$messageIds = $this->sdoFactory->index("medona/message", ["messageId"], "(status='received' OR status='modified') AND type='ArchiveTransfer' AND active=true");
// Avoid paralleling processes
foreach ($messageIds as $messageId) {
$message = $this->sdoFactory->read('medona/message', (string) $messageId);
if (!in_array($message->status, ['received', 'modified'])) {
continue;
}
$this->changeStatus($message->messageId, "processing");
$messages = $this->sdoFactory->find("medona/message", "(status='received' OR status='modified') AND type='ArchiveTransfer' AND active=true");
foreach ($messages as $message) {
$this->loadData($message);
try {
......@@ -738,11 +748,17 @@ class ArchiveTransfer extends abstractMessage
{
$results = array();
$messages = $this->sdoFactory->find("medona/message", "status='accepted' AND type='ArchiveTransfer' AND active=true");
foreach ($messages as $message) {
$messageIds = $this->sdoFactory->index("medona/message", ["messageId"], "status='accepted' AND type='ArchiveTransfer' AND active=true");
foreach ($messageIds as $messageId) {
// Avoid paralleling processing
$message = $this->sdoFactory->read('medona/message', (string) $messageId);
if (!$message->status != 'accepted') {
continue;
}
$this->changeStatus($message->messageId, "processing");
}
foreach ($messages as $message) {
$this->loadData($message);
try {
......
......@@ -622,6 +622,13 @@ trait archiveModificationTrait
$retentionRules = [];
foreach ($archives as $archive) {
// avoid parallel processing
if ($this->sdoFactory->read('recordsManagement/archive')->retentionRuleStatus != "changed") {
continue;
}
$archive->retentionRuleStatus = "processing";
$this->sdoFactory->update($archive, 'recordsManagement/archiveRetentionRule');
$retentionRule = new \stdClass();
$retentionRule->archiveId = $archive->archiveId;
$retentionRule->previousStartDate = $archive->retentionStartDate;
......
Supports Markdown
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