1010
1111use Magento \Framework \MessageQueue \PublisherInterface ;
1212use Magento \Framework \OsInfo ;
13+ use Magento \TestFramework \Helper \Bootstrap ;
1314use Magento \TestFramework \Helper \Amqp ;
1415
1516class PublisherConsumerController
@@ -49,6 +50,11 @@ class PublisherConsumerController
4950 */
5051 private $ amqpHelper ;
5152
53+ /**
54+ * @var ClearQueueProcessor
55+ */
56+ private $ clearQueueProcessor ;
57+
5258 /**
5359 * PublisherConsumerController constructor.
5460 * @param PublisherInterface $publisher
@@ -58,6 +64,7 @@ class PublisherConsumerController
5864 * @param array $consumers
5965 * @param array $appInitParams
6066 * @param null|int $maxMessages
67+ * @param ClearQueueProcessor $clearQueueProcessor
6168 */
6269 public function __construct (
6370 PublisherInterface $ publisher ,
@@ -66,7 +73,8 @@ public function __construct(
6673 $ logFilePath ,
6774 $ consumers ,
6875 $ appInitParams ,
69- $ maxMessages = null
76+ $ maxMessages = null ,
77+ ClearQueueProcessor $ clearQueueProcessor = null
7078 ) {
7179 $ this ->consumers = $ consumers ;
7280 $ this ->publisher = $ publisher ;
@@ -75,6 +83,8 @@ public function __construct(
7583 $ this ->osInfo = $ osInfo ;
7684 $ this ->appInitParams = $ appInitParams ;
7785 $ this ->amqpHelper = $ amqpHelper ;
86+ $ this ->clearQueueProcessor = $ clearQueueProcessor
87+ ?: Bootstrap::getObjectManager ()->get (ClearQueueProcessor::class);
7888 }
7989
8090 /**
@@ -87,12 +97,7 @@ public function initialize()
8797 {
8898 $ this ->validateEnvironmentPreconditions ();
8999
90- $ connections = $ this ->amqpHelper ->getConnections ();
91- foreach (array_keys ($ connections ) as $ connectionName ) {
92- $ this ->amqpHelper ->deleteConnection ($ connectionName );
93- }
94- $ this ->amqpHelper ->clearQueue ("async.operations.all " );
95-
100+ $ this ->clearQueueProcessor ->execute ("async.operations.all " );
96101 $ this ->stopConsumers ();
97102 $ this ->startConsumers ();
98103
@@ -120,12 +125,6 @@ private function validateEnvironmentPreconditions()
120125 "This test relies on *nix shell and should be skipped in Windows environment. "
121126 );
122127 }
123-
124- if (!$ this ->amqpHelper ->isAvailable ()) {
125- throw new PreconditionFailedException (
126- 'This test relies on RabbitMQ Management Plugin. '
127- );
128- }
129128 }
130129
131130 /**
0 commit comments