10
10
11
11
use Magento \Framework \MessageQueue \PublisherInterface ;
12
12
use Magento \Framework \OsInfo ;
13
+ use Magento \TestFramework \Helper \Bootstrap ;
13
14
use Magento \TestFramework \Helper \Amqp ;
14
15
15
16
class PublisherConsumerController
@@ -49,6 +50,11 @@ class PublisherConsumerController
49
50
*/
50
51
private $ amqpHelper ;
51
52
53
+ /**
54
+ * @var ClearQueueProcessor
55
+ */
56
+ private $ clearQueueProcessor ;
57
+
52
58
/**
53
59
* PublisherConsumerController constructor.
54
60
* @param PublisherInterface $publisher
@@ -58,6 +64,7 @@ class PublisherConsumerController
58
64
* @param array $consumers
59
65
* @param array $appInitParams
60
66
* @param null|int $maxMessages
67
+ * @param ClearQueueProcessor $clearQueueProcessor
61
68
*/
62
69
public function __construct (
63
70
PublisherInterface $ publisher ,
@@ -66,7 +73,8 @@ public function __construct(
66
73
$ logFilePath ,
67
74
$ consumers ,
68
75
$ appInitParams ,
69
- $ maxMessages = null
76
+ $ maxMessages = null ,
77
+ ClearQueueProcessor $ clearQueueProcessor = null
70
78
) {
71
79
$ this ->consumers = $ consumers ;
72
80
$ this ->publisher = $ publisher ;
@@ -75,6 +83,8 @@ public function __construct(
75
83
$ this ->osInfo = $ osInfo ;
76
84
$ this ->appInitParams = $ appInitParams ;
77
85
$ this ->amqpHelper = $ amqpHelper ;
86
+ $ this ->clearQueueProcessor = $ clearQueueProcessor
87
+ ?: Bootstrap::getObjectManager ()->get (ClearQueueProcessor::class);
78
88
}
79
89
80
90
/**
@@ -87,12 +97,7 @@ public function initialize()
87
97
{
88
98
$ this ->validateEnvironmentPreconditions ();
89
99
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 " );
96
101
$ this ->stopConsumers ();
97
102
$ this ->startConsumers ();
98
103
@@ -120,12 +125,6 @@ private function validateEnvironmentPreconditions()
120
125
"This test relies on *nix shell and should be skipped in Windows environment. "
121
126
);
122
127
}
123
-
124
- if (!$ this ->amqpHelper ->isAvailable ()) {
125
- throw new PreconditionFailedException (
126
- 'This test relies on RabbitMQ Management Plugin. '
127
- );
128
- }
129
128
}
130
129
131
130
/**
0 commit comments