-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5897 from magento-performance/MC-35827-2
Fixed issues: - MC-35884 Consumers improvement - MC-35827 Test and merge PR with extended message queue consumer configuration
- Loading branch information
Showing
26 changed files
with
788 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/code/Magento/MessageQueue/Model/CheckIsAvailableMessagesInQueue.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\MessageQueue\Model; | ||
|
||
use Magento\Framework\MessageQueue\QueueRepository; | ||
|
||
/** | ||
* Class CheckIsAvailableMessagesInQueue for checking messages available in queue | ||
*/ | ||
class CheckIsAvailableMessagesInQueue | ||
{ | ||
/** | ||
* @var QueueRepository | ||
*/ | ||
private $queueRepository; | ||
|
||
/** | ||
* Initialize dependencies. | ||
* | ||
* @param QueueRepository $queueRepository | ||
*/ | ||
public function __construct(QueueRepository $queueRepository) | ||
{ | ||
$this->queueRepository = $queueRepository; | ||
} | ||
|
||
/** | ||
* Checks if there is available messages in the queue | ||
* | ||
* @param string $connectionName connection name | ||
* @param string $queueName queue name | ||
* @return bool | ||
* @throws \LogicException if queue is not available | ||
*/ | ||
public function execute($connectionName, $queueName) | ||
{ | ||
$queue = $this->queueRepository->get($connectionName, $queueName); | ||
$message = $queue->dequeue(); | ||
if ($message) { | ||
$queue->reject($message); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.