Skip to content

Commit b6a66b3

Browse files
committed
#1724: Support batches processing for synchronization queue messages - updated synchronization consumer and added media content bulk service
1 parent 7198c76 commit b6a66b3

File tree

3 files changed

+63
-6
lines changed

3 files changed

+63
-6
lines changed

app/code/Magento/MediaContentSynchronization/Model/Consume.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\MediaContentSynchronization\Model;
99

10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\MediaContentSynchronizationApi\Api\SynchronizeIdentitiesInterface;
1012
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;
1113

1214
/**
@@ -19,19 +21,34 @@ class Consume
1921
*/
2022
private $synchronize;
2123

24+
/**
25+
* @var SynchronizeIdentitiesInterface
26+
*/
27+
private $synchronizeIdentities;
28+
2229
/**
2330
* @param SynchronizeInterface $synchronize
31+
* @param SynchronizeIdentitiesInterface $synchronizeIdentities
2432
*/
25-
public function __construct(SynchronizeInterface $synchronize)
26-
{
33+
public function __construct(
34+
SynchronizeInterface $synchronize,
35+
SynchronizeIdentitiesInterface $synchronizeIdentities
36+
) {
2737
$this->synchronize = $synchronize;
38+
$this->synchronizeIdentities = $synchronizeIdentities;
2839
}
2940

3041
/**
3142
* Run media files synchronization.
43+
* @param string[] $message
44+
* @throws LocalizedException
3245
*/
33-
public function execute() : void
46+
public function execute(array $message) : void
3447
{
3548
$this->synchronize->execute();
49+
50+
if (!empty($message)) {
51+
$this->synchronizeIdentities->execute($message);
52+
}
3653
}
3754
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\MediaContentSynchronizationApi\Api;
9+
10+
use Magento\MediaContentApi\Api\Data\ContentIdentityInterface;
11+
12+
/**
13+
* Synchronize bulk assets and contents
14+
*/
15+
interface SynchronizeIdentitiesInterface
16+
{
17+
/**
18+
* Synchronize media contents
19+
*
20+
* @param ContentIdentityInterface[] $contentIdentities
21+
*/
22+
public function execute(array $contentIdentities): void;
23+
}

app/code/Magento/MediaGallerySynchronization/Model/Consume.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\MediaGallerySynchronization\Model;
99

10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\MediaGallerySynchronizationApi\Api\SynchronizeFilesInterface;
1012
use Magento\MediaGallerySynchronizationApi\Api\SynchronizeInterface;
1113

1214
/**
@@ -19,19 +21,34 @@ class Consume
1921
*/
2022
private $synchronize;
2123

24+
/**
25+
* @var SynchronizeFilesInterface
26+
*/
27+
private $synchronizeFiles;
28+
2229
/**
2330
* @param SynchronizeInterface $synchronize
31+
* @param SynchronizeFilesInterface $synchronizeFiles
2432
*/
25-
public function __construct(SynchronizeInterface $synchronize)
26-
{
33+
public function __construct(
34+
SynchronizeInterface $synchronize,
35+
SynchronizeFilesInterface $synchronizeFiles
36+
) {
2737
$this->synchronize = $synchronize;
38+
$this->synchronizeFiles = $synchronizeFiles;
2839
}
2940

3041
/**
3142
* Run media files synchronization.
43+
* @param string[] $message
44+
* @throws LocalizedException
3245
*/
33-
public function execute() : void
46+
public function execute(array $message) : void
3447
{
3548
$this->synchronize->execute();
49+
50+
if (!empty($message)) {
51+
$this->synchronizeFiles->execute($message);
52+
}
3653
}
3754
}

0 commit comments

Comments
 (0)