本文整理汇总了PHP中AMQPExchange::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPExchange::getName方法的具体用法?PHP AMQPExchange::getName怎么用?PHP AMQPExchange::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMQPExchange
的用法示例。
在下文中一共展示了AMQPExchange::getName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bind
/**
* Bind queue to exchange using dispatcher event names as routing keys
*
* @return void
* @throws AMQPExchangeException
*/
public function bind(\AMQPQueue $queue, \AMQPExchange $exchange)
{
$events = preg_grep($this->pattern, array_keys($this->getDispatcher()->getListeners()));
foreach ($events as $eventName) {
$queue->bind($exchange->getName(), $eventName);
}
$this->dispatcher->dispatch(static::BIND_EVENT, new SymfonyEvent($events, ["pattern" => $this->pattern, "exchange" => $exchange->getName(), "queue" => $queue->getName()]));
}
示例2: receive
/**
* {@inheritDoc}
*/
public function receive(array $eventNames, \Closure $callback)
{
$exchangeName = $this->exchange->getName();
foreach ($eventNames as $eventName) {
$this->queue->bind($exchangeName, $eventName);
}
$this->queue->consume(function (\AMQPEnvelope $envelope, \AMQPQueue $queue) use($callback) {
$message = $envelope->getBody();
$messageTag = $envelope->getDeliveryTag();
$status = call_user_func($callback, $message);
if ($status) {
$queue->ack($messageTag);
} else {
$queue->nack($messageTag);
}
});
}
示例3: getExchange
/**
* @return \AMQPExchange
* @throws \Exception
*/
protected function getExchange()
{
if (!$this->exchange) {
$this->exchange = new \AMQPExchange($this->getChannel());
$this->exchange->setName($this->exchangeConfig['name']);
$this->exchange->setType($this->exchangeConfig['type']);
$this->exchange->setArguments($this->exchangeConfig['arguments']);
$this->exchange->setFlags($this->exchangeConfig['flags']);
if (!$this->exchange->declareExchange()) {
throw new \Exception('Can not declare exchange ' . $this->exchange->getName());
}
}
return $this->exchange;
}
示例4: castExchange
public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
$a += array($prefix . 'name' => $c->getName(), $prefix . 'flags' => self::extractFlags($c->getFlags()), $prefix . 'type' => isset(self::$exchangeTypes[$c->getType()]) ? new ConstStub(self::$exchangeTypes[$c->getType()], $c->getType()) : $c->getType(), $prefix . 'arguments' => $c->getArguments(), $prefix . 'channel' => $c->getChannel(), $prefix . 'connection' => $c->getConnection());
return $a;
}
示例5: microtime
}
$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();
示例6: getExchange
public function getExchange($name = 'default', $channelName = 'default')
{
$key = $channelName . '_' . $name;
if (!isset($this->exchanges[$key])) {
$channel = $this->getChannel($channelName);
if (!isset($this->exchangesSettings[$name])) {
throw new \LogicException('No settings for exchange ' . $name);
}
$settings = $this->exchangesSettings[$name];
$exchange = new \AMQPExchange($channel);
$exchange->setName($settings['name']);
if (strpos($settings['name'], 'amq.') !== 0) {
$queueFlags = AMQP_NOPARAM;
if ($settings['durable']) {
$queueFlags |= AMQP_DURABLE;
}
if ($settings['passive']) {
$queueFlags |= AMQP_PASSIVE;
}
if ($settings['autoDelete']) {
$queueFlags |= AMQP_AUTODELETE;
}
$exchange->setType($this->getExchangeType($settings['type']));
$exchange->setFlags($queueFlags);
$exchange->declareExchange();
}
$this->exchanges[$key] = $exchange;
//Warning place possible circular links
if ($settings['to_exchanges'] !== null) {
foreach ($settings['to_exchanges'] as $binExchangeName => $routingKeys) {
$bindExchange = $this->getExchange($binExchangeName, $channelName);
foreach ($routingKeys as $routingKey) {
$bindExchange->bind($exchange->getName(), $routingKey);
}
}
}
}
return $this->exchanges[$key];
}
示例7: getName
/**
* @return string
*/
public function getName()
{
return $this->rawExchange->getName();
}
示例8: getExchangeForQueue
/**
* @param \AMQPQueue $queue
*
* @return \AMQPExchange
*/
protected function getExchangeForQueue(\AMQPQueue $queue)
{
$amqpExchange = new \AMQPExchange($this->channel);
$queueOptions = $this->getOptionsForQueue($queue->getName());
// determine exchange to use
if (array_key_exists('exchange', $queueOptions) && trim($queueOptions['exchange'])) {
$amqpExchange->setName((string) $queueOptions['exchange']);
}
$options = $this->getOptionsForExchange($amqpExchange->getName());
$flags = $this->getFlagsFromOptions(['durable', 'passive'], $options);
$amqpExchange->setFlags($flags);
$amqpExchange->setType(isset($options['type']) ? $options['type'] : AMQP_EX_TYPE_DIRECT);
return $amqpExchange;
}
示例9: getName
/**
* @inheritdoc
*/
public function getName()
{
return $this->delegate->getName();
}
示例10: getName
/**
* @inheritdoc
*/
public function getName() : string
{
return $this->exchange->getName() ?: '';
}
示例11: send
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();
}