本文整理汇总了PHP中AMQPQueue::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPQueue::getName方法的具体用法?PHP AMQPQueue::getName怎么用?PHP AMQPQueue::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMQPQueue
的用法示例。
在下文中一共展示了AMQPQueue::getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: AMQPConnection
$connection = new AMQPConnection();
$connection->setHost('127.0.0.1');
$connection->setLogin('guest');
$connection->setPassword('guest');
$connection->connect();
//Create and declare channel
$channel = new AMQPChannel($connection);
try {
//Declare Exchange
$exchange_name = 'logs';
$exchange = new AMQPExchange($channel);
$exchange->setType(AMQP_EX_TYPE_FANOUT);
$exchange->setName($exchange_name);
$exchange->declareExchange();
//Do not declasre the queue name by setting AMQPQueue::setName()
$queue = new AMQPQueue($channel);
$queue->setFlags(AMQP_EXCLUSIVE);
$queue->declareQueue();
$queue->bind($exchange_name, $queue->getName());
echo sprintf("Queue Name: %s", $queue->getName()), PHP_EOL;
} catch (Exception $ex) {
print_r($ex);
}
//Read from stdin
$message = implode(' ', array_slice($argv, 1));
if (empty($message)) {
$message = "info: Hello World!";
}
$exchange->publish($message, '');
echo " [X] Sent {$message}", PHP_EOL;
$connection->disconnect();
示例3: castQueue
public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
$a += array($prefix . 'name' => $c->getName(), $prefix . 'flags' => self::extractFlags($c->getFlags()), $prefix . 'arguments' => $c->getArguments(), $prefix . 'connection' => $c->getConnection(), $prefix . 'channel' => $c->getChannel());
return $a;
}
示例4: getName
/**
* @inheritdoc
*/
public function getName() : string
{
return $this->queue->getName();
}
示例5: getName
/**
* @inheritdoc
*/
public function getName()
{
return $this->delegate->getName();
}
示例6: function
$callback_func = function (AMQPEnvelope $message, AMQPQueue $q) use(&$max_jobs) {
echo " [x] Received: ", $message->getBody(), PHP_EOL;
sleep(1);
$q->nack($message->getDeliveryTag());
};
try {
//Declare Exchange
$exchange_name = 'logs';
$exchange = new AMQPExchange($channel);
$exchange->setType(AMQP_EX_TYPE_FANOUT);
$exchange->setName($exchange_name);
$exchange->declareExchange();
$queue = new AMQPQueue($channel);
$queue->setFlags(AMQP_EXCLUSIVE);
//allow server to define name
$queue->declareQueue();
$queue->bind($exchange_name, $queue->getName());
echo ' [*] Waiting for logs. To exit press CTRL+C', PHP_EOL;
$queue->consume($callback_func);
} catch (AMQPQueueException $ex) {
print_r($ex);
} catch (AMQPExchangeException $ex) {
print_r($ex);
} catch (AMQPChanncelException $ex) {
print_r($ex);
} catch (AMQPConnectionException $ex) {
print_r($ex);
} catch (Exception $ex) {
print_r($ex);
}
$connection->disconnect();
示例7: getQueue
/**
* @param $name
* @param string $channelName
* @return \AMQPQueue
*/
public function getQueue($name = 'default', $channelName = 'default')
{
$key = $channelName . '_' . $name;
if (!isset($this->queues[$key])) {
$channel = $this->getChannel($channelName);
if (!isset($this->queuesSettings[$name])) {
throw new \LogicException('No settings for queue ' . $name);
}
$settings = $this->queuesSettings[$name];
$queue = new \AMQPQueue($channel);
if ($settings['name'] !== null) {
$queue->setName($settings['name']);
}
$queueFlags = AMQP_NOPARAM;
if ($settings['durable']) {
$queueFlags |= AMQP_DURABLE;
}
if ($settings['exclusive']) {
$queueFlags |= AMQP_EXCLUSIVE;
}
if ($settings['autoDelete']) {
$queueFlags |= AMQP_AUTODELETE;
}
if ($settings['passive']) {
$queueFlags |= AMQP_PASSIVE;
}
$queue->setFlags($queueFlags);
$queue->declareQueue();
$this->queuesSettings[$name]['name'] = $queue->getName();
$this->queues[$key] = $queue;
//Warning place possible circular links
if ($settings['from_exchanges'] !== null) {
foreach ($settings['from_exchanges'] as $binExchangeName => $routingKeys) {
$bindExchange = $this->getExchange($binExchangeName, $channelName);
foreach ($routingKeys as $routingKey) {
$queue->bind($bindExchange->getName(), $routingKey);
}
}
}
}
return $this->queues[$key];
}
示例8: getQueueName
/**
* {@inheritDoc}
*/
public function getQueueName()
{
return $this->queue->getName();
}
示例9: 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;
}
示例10: execute
public function execute(\AMQPEnvelope $envelope, \AMQPQueue $queue)
{
echo 'Receive `' . $envelope->getBody() . '` from queue `' . $queue->getName() . '`' . PHP_EOL;
}
示例11: declareQueue
/**
* Declare new queue in AMQP broker
*
* @param string $name Queue name
* @param bool $durable Is queue durable
* @param bool $exclusive Is queue exclusive
*
* @return string New queue name
*
* @throws ConnectionException
* @throws \AMQPException
*/
public function declareQueue($name, $durable = true, $exclusive = false)
{
try {
$queue = new \AMQPQueue($this->getChannel());
if ($name !== null) {
$queue->setName((string) $name);
}
$flags = AMQP_NOPARAM;
$flags |= $durable ? AMQP_DURABLE : AMQP_NOPARAM;
$flags |= $exclusive ? AMQP_EXCLUSIVE : AMQP_NOPARAM;
$queue->setFlags($flags);
$queue->declareQueue();
return $queue->getName();
} catch (\AMQPConnectionException $e) {
$this->channel = null;
throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
} catch (\AMQPException $e) {
$this->channel = null;
throw $e;
}
}
示例12: getName
/**
* @return string
*/
public function getName()
{
return $this->rawQueue->getName();
}