本文整理汇总了PHP中AMQPQueue::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPQueue::setName方法的具体用法?PHP AMQPQueue::setName怎么用?PHP AMQPQueue::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMQPQueue
的用法示例。
在下文中一共展示了AMQPQueue::setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSrvQueue
/**
* @return \AMQPQueue
*/
public function getSrvQueue()
{
if ($this->srvQueue === null) {
$chanel = $this->getChanel();
/* create a queue object */
$this->srvQueue = new \AMQPQueue($chanel);
$this->srvQueue->setName($this->queueName);
$this->srvQueue->setFlags(AMQP_DURABLE);
$this->srvQueue->declareQueue();
}
return $this->srvQueue;
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(sprintf('Move messages from queue "%s" (vhost: "%s") to exchange "%s" with routingKey "%s" (vhost: "%s")', $input->getArgument('from_queue'), $input->getArgument('from_vhost'), $input->getArgument('to_exchange'), $input->getArgument('to_routing_key'), $input->getArgument('to_vhost')));
$fromChannel = $this->getChannel($input->getArgument('from_connection'), $input->getArgument('from_vhost'));
if (null === ($toConnectionName = $input->getOption('to_connection'))) {
$toChannel = $this->getChannel($input->getArgument('from_connection'), $input->getArgument('to_vhost'));
} else {
$toChannel = $this->getChannel($input->getOption('to_connection'), $input->getArgument('to_vhost'));
}
$queue = new \AMQPQueue($fromChannel);
$queue->setName($input->getArgument('from_queue'));
$exchange = new \AMQPExchange($toChannel);
$exchange->setName($input->getArgument('to_exchange'));
$messageProvider = new PeclPackageMessageProvider($queue);
$messagePublisher = new PeclPackageMessagePublisher($exchange);
$options = array();
$stack = new \Swarrot\Processor\Stack\Builder();
if (0 !== ($max = (int) $input->getOption('max-messages'))) {
$stack->push('Swarrot\\Processor\\MaxMessages\\MaxMessagesProcessor');
$options['max_messages'] = $max;
}
$stack->push('Swarrot\\Processor\\Insomniac\\InsomniacProcessor');
$stack->push('Swarrot\\Processor\\Ack\\AckProcessor', $messageProvider);
$processor = $stack->resolve(new MoveProcessor($messagePublisher, $input->getArgument('to_routing_key')));
$consumer = new Consumer($messageProvider, $processor);
$consumer->consume($options);
}
示例3: _initPublisher
private function _initPublisher()
{
if (!$this->open()) {
return false;
}
if ($this->_exchange) {
return true;
}
$channel = new AMQPChannel($this->_conn);
//创建exchange
$this->_exchange = new AMQPExchange($channel);
$this->_exchange->setName($this->_connInfo['exchangeName']);
$this->_exchange->setType(AMQP_EX_TYPE_DIRECT);
$this->_exchange->setFlags(AMQP_DURABLE);
if (!$this->_exchange->declareExchange()) {
$this->close();
return false;
}
//创建队列,生产者和消费者都要创建队列
$queue = new AMQPQueue($channel);
$queue->setName($this->_connInfo['queueName']);
$queue->setFlags(AMQP_DURABLE);
$queue->declareQueue();
$queue->bind($this->_connInfo['exchangeName'], $this->_connInfo['routingKey']);
return true;
}
示例4: declareQueue
public function declareQueue($name, $flags = AMQP_DURABLE)
{
$queue = new \AMQPQueue($this->channel);
$queue->setName($name);
$queue->setFlags($flags);
$queue->declareQueue();
return $queue;
}
示例5: getAMQPQueue
protected function getAMQPQueue($name)
{
$connection = new \AMQPConnection(array('vhost' => 'swarrot'));
$connection->connect();
$channel = new \AMQPChannel($connection);
$queue = new \AMQPQueue($channel);
$queue->setName($name);
return $queue;
}
示例6: register
/**
* {@inheritDoc}
*/
public function register(Container $c)
{
$c['amqp.connections.initializer'] = function ($c) {
$config = $c['amqp.options'];
$connections = array();
if (isset($config['connections'])) {
foreach ($config['connections'] as $name => $options) {
$connections[$name] = new \AMQPConnection($options);
}
return $connections;
}
if (isset($config['connection'])) {
return array('default' => new \AMQPConnection($config['connection']));
}
throw new \LogicException('No connection defined');
};
$c['queue.factory'] = function ($c) {
$connections = $c['amqp.connections.initializer'];
return function ($queueName, $connectionName = null) use($connections) {
$names = array_keys($connections);
if (null === $connectionName) {
$connectionName = reset($names);
}
if (!array_key_exists($connectionName, $connections)) {
throw new \InvalidArgumentException(sprintf('Unknown connection "%s". Available: [%s]', $connectionName, implode(', ', $names)));
}
$connection = $connections[$connectionName];
if (!$connection->isConnected()) {
$connection->connect();
}
$channel = new \AMQPChannel($connection);
$queue = new \AMQPQueue($channel);
$queue->setName($queueName);
return $queue;
};
};
$c['exchange.factory'] = function ($c) {
$connections = $c['amqp.connections.initializer'];
return function ($exchangeName, $connectionName = null) use($connections) {
$names = array_keys($connections);
if (null === $connectionName) {
$connectionName = reset($names);
}
if (!array_key_exists($connectionName, $connections)) {
throw new \InvalidArgumentException(sprintf('Unknown connection "%s". Available: [%s]', $connectionName, implode(', ', $names)));
}
$connection = $connections[$connectionName];
if (!$connection->isConnected()) {
$connection->connect();
}
$channel = new \AMQPChannel($connection);
$exchange = new \AMQPExchange($channel);
$exchange->setName($exchangeName);
return $exchange;
};
};
}
示例7: getQueue
/**
* @param string $name
*
* @return \AMQPQueue
*/
protected function getQueue($name)
{
if (!isset($this->queues[$name])) {
$queue = new \AMQPQueue($this->getChannel());
$queue->setName($name);
$this->queues[$name] = $queue;
}
return $this->queues[$name];
}
示例8: get
public function get($queueName, $timeout = null)
{
if (null === $this->queue) {
$queue = new \AMQPQueue($this->channel);
$queue->setName($queueName);
$queue->declare();
}
return unserialize($queue->consume());
}
示例9: createQueue
/**
* @inheritdoc
*/
public function createQueue(ChannelInterface $channel, $name = null, $flags = null, array $args = [])
{
$delegate = new \AMQPQueue($channel->getDelegate());
$delegate->setFlags(Queue::convertToDelegateFlags($flags));
$delegate->setArguments($args);
if (null !== $name) {
$delegate->setName($name);
}
return new Queue($delegate, $channel);
}
示例10: init
/**
* AMQP queue initialization
* @param string $name Queue name
* @param string $mode Access mode: r is for reading and w is for writing
* @return \AMQPQueue
*/
public function init($name, $mode = 'w')
{
$queue = new \AMQPQueue($this->channel);
$queue->setName($name);
$queue->declare();
if ($mode == 'r') {
$queue->bind('Celium', $name);
}
return $queue;
}
示例11: getQueue
/**
* @return \AMQPQueue
*/
protected function getQueue()
{
if (!$this->queue) {
$this->queue = new \AMQPQueue($this->getChannel());
$this->queue->setName($this->queueConfig['name']);
$this->queue->setFlags($this->queueConfig['flags']);
$this->queue->declareQueue();
}
return $this->queue;
}
示例12: take
public function take()
{
$q = new \AMQPQueue($this->amqpChannel);
$q->setName($this->name);
$msg = $q->get();
if (empty($msg)) {
return false;
} else {
return new MessageTakeControl($q, $msg);
}
}
示例13: getQueue
/**
* getQueue.
*
* @param string $name
* @param string $connection
*
* @return \AMQPQueue
*/
public function getQueue($name, $connection)
{
if (!isset($this->queues[$connection][$name])) {
if (!isset($this->queues[$connection])) {
$this->queues[$connection] = array();
}
$queue = new \AMQPQueue($this->getChannel($connection));
$queue->setName($name);
$this->queues[$connection][$name] = $queue;
}
return $this->queues[$connection][$name];
}
示例14: it_should_initialize
public function it_should_initialize(\AMQPQueue $queue, Exchange $exchange, Context $context)
{
$exchange->getName()->willReturn('exchange');
$context->getFlags()->willReturn(1234);
$context->getArguments()->willReturn(['foo' => 'bar']);
$queue->setName('queue')->shouldBeCalled();
$queue->bind('exchange')->shouldBeCalled();
$queue->setFlags(1234)->shouldBeCalled();
$queue->setArguments(['foo' => 'bar'])->shouldBeCalled();
$queue->declareQueue()->shouldBeCalled();
$this->initialize($queue);
$this->isInitialized()->shouldReturn(true);
}
示例15: subscribe
public function subscribe($topic, $queueName, $process_callback)
{
$channel = new AMQPChannel($this->amqpConnection);
$channel->setPrefetchCount(0);
$queue = new AMQPQueue($channel);
$queue->setName($queueName);
$queue->setFlags(AMQP_DURABLE);
$queue->declareQueue();
$queue->bind('topic', $topic);
$queue->consume($process_callback);
if (!$this->amqpConnection->disconnect()) {
throw new Exception("Could not disconnect !");
}
}