Skip to content

Commit b9ae74c

Browse files
erikverheijDavertMik
authored andcommitted
Add methods to bind an (non-existent) exchange to a (non-existent) queue in AMPQ module (#3988)
1 parent 14d85f4 commit b9ae74c

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/Codeception/Module/AMQP.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,63 @@ public function pushToQueue($queue, $message)
154154
$this->connection->channel()->basic_publish($message, '', $queue);
155155
}
156156

157+
/**
158+
* Declares an exchange
159+
*
160+
* This is an alias of method `exchange_declare` of `PhpAmqpLib\Channel\AMQPChannel`.
161+
*
162+
* ```php
163+
* <?php
164+
* $I->declareExchange(
165+
* 'nameOfMyExchange', // exchange name
166+
* 'topic' // exchange type
167+
* //.. see the original method for more options
168+
* )
169+
* ```
170+
*/
171+
public function declareExchange()
172+
{
173+
return call_user_func_array([$this->connection->channel(), 'exchange_declare'], func_get_args());
174+
}
175+
176+
/**
177+
* Declares a queue
178+
*
179+
* This is an alias of method `queue_declare` of `PhpAmqpLib\Channel\AMQPChannel`.
180+
*
181+
* ```php
182+
* <?php
183+
* $I->declareQueue(
184+
* 'nameOfMyQueue', // exchange name
185+
* //.. see the original method for more options
186+
* )
187+
* ```
188+
*/
189+
public function declareQueue()
190+
{
191+
return call_user_func_array([$this->connection->channel(), 'queue_declare'], func_get_args());
192+
}
193+
194+
/**
195+
* Binds a queue to an exchange
196+
*
197+
* This is an alias of method `queue_bind` of `PhpAmqpLib\Channel\AMQPChannel`.
198+
*
199+
* ```php
200+
* <?php
201+
* $I->bindQueueToExchange(
202+
* 'nameOfMyQueueToBind', // name of the queue
203+
* 'transactionTracking.transaction', // exchange name to bind to
204+
* 'your.routing.key' // Optionally, provide a binding key
205+
* //.. see the original method for more options
206+
* )
207+
* ```
208+
*/
209+
public function bindQueueToExchange()
210+
{
211+
return call_user_func_array([$this->connection->channel(), 'queue_bind'], func_get_args());
212+
}
213+
157214
/**
158215
* Checks if message containing text received.
159216
*

0 commit comments

Comments
 (0)