delete() public method

Delete the exchange from the broker.
public delete ( string $exchangeName = null, integer $flags = AMQP_NOPARAM ) : boolean
$exchangeName string Optional name of exchange to delete.
$flags integer Optionally AMQP_IFUNUSED can be specified to indicate the exchange should not be deleted until no clients are connected to it.
return boolean true on success or false on failure.
Beispiel #1
0
 /**
  * @param string $exchangeName
  * @param int    $flags
  *
  * @return bool
  */
 public function delete($exchangeName = null, $flags = Client::NOPARAM)
 {
     try {
         return $this->rawExchange->delete($exchangeName, $flags);
     } catch (\Exception $e) {
         ClientHelper::throwRightException($e);
     }
 }
Beispiel #2
0
 /**
  * @inheritdoc
  */
 public function delete($exchangeName = null, $flags = null)
 {
     try {
         return $this->delegate->delete($exchangeName, self::convertToDelegateFlags($flags));
     } catch (\AMQPExchangeException $e) {
         throw new ExchangeException($e->getMessage(), $e->getCode(), $e);
     } catch (\AMQPChannelException $e) {
         throw new ChannelException($e->getMessage(), $e->getCode(), $e);
     } catch (\AMQPConnectionException $e) {
         throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
     }
 }
Beispiel #3
0
$timer = microtime(true) - $timer;
echo '    Get: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL;
$q->delete();
$exchange->delete();
echo PHP_EOL;
// ==================================
$exchange = new AMQPExchange($ch);
$exchange->setType(AMQP_EX_TYPE_FANOUT);
$exchange->setFlags(AMQP_AUTODELETE);
$exchange->setName('benchmark_exchange_' . microtime(true));
$exchange->declareExchange();
$q = new AMQPQueue($ch);
$q->setFlags(AMQP_AUTODELETE);
$q->declareQueue();
$q->bind($exchange->getName());
$timer = microtime(true);
for ($i = 0; $i < $iterations; $i++) {
    $exchange->publish($message);
}
$timer = microtime(true) - $timer;
echo 'Publish: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL;
$consumer_iterations = $iterations;
$timer = microtime(true);
$q->consume(function () use(&$consumer_iterations) {
    return --$consumer_iterations > 0;
}, AMQP_AUTOACK);
$timer = microtime(true) - $timer;
echo 'Consume: ', $iterations, ' iterations took ', $timer, 'sec', PHP_EOL;
$q->delete();
$exchange->delete();
Beispiel #4
0
<?php

// print_r( get_loaded_extensions() );
$cnn = new AMQPConnection();
echo "------  connect ...  --------\n";
$ret = $cnn->connect();
echo "------  connect Ok  --------\n";
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
echo "------  exchange Ok  --------\n";
// $cnn->disconnect(AMQP_NOPARAM);
$ex->setName('test_e');
$ex->delete();
$cnn->disconnect();
Beispiel #5
0
 /**
  * @inheritdoc
  */
 public function delete(string $exchangeName = '', int $flags = Constants::AMQP_NOPARAM)
 {
     $this->exchange->delete($exchangeName, $flags);
 }
Beispiel #6
0
 private function send($msg)
 {
     // Attach to well known server ETL and send message.
     $request_queue = new AMQPQueue($this->channel);
     $request_queue->setName("queue-well-known-rpc-name");
     $request_queue->declareQueue();
     $request_exch = new AMQPExchange($this->channel);
     $request_exch->setName("exchange-well-known-rpc-name");
     $request_exch->setType(AMQP_EX_TYPE_FANOUT);
     $request_exch->declareExchange();
     $request_queue->bind($request_exch->getName());
     $request_exch->publish($msg, null, AMQP_NOPARAM, ['correlation_id' => $this->correlation_id, 'reply_to' => $this->reply_queue->getName()]);
     $request_exch->delete();
 }