当前位置: 首页>>代码示例>>PHP>>正文


PHP AMQPExchange::setFlags方法代码示例

本文整理汇总了PHP中AMQPExchange::setFlags方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPExchange::setFlags方法的具体用法?PHP AMQPExchange::setFlags怎么用?PHP AMQPExchange::setFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AMQPExchange的用法示例。


在下文中一共展示了AMQPExchange::setFlags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initialize

 /**
  * @param \AMQPExchange|null $exchange
  *
  * @throws HectorException
  */
 public function initialize(\AMQPExchange $exchange = null)
 {
     if (null == $exchange) {
         $exchange = new \AMQPExchange($this->channel->getWrappedChannel());
     }
     $this->exchange = $exchange;
     $this->exchange->setName($this->getName());
     $this->exchange->setType($this->context->getType());
     $this->exchange->setArguments($this->context->getArguments());
     $this->exchange->setFlags((int) $this->context->getFlags());
     $this->exchange->declareExchange();
     $this->initialized = true;
 }
开发者ID:Evaneos,项目名称:Hector,代码行数:18,代码来源:Exchange.php

示例2: declareExchange

 public function declareExchange($name, $type = AMQP_EX_TYPE_TOPIC, $flags = AMQP_DURABLE)
 {
     $exchange = new \AMQPExchange($this->channel);
     $exchange->setName($name);
     $exchange->setType($type);
     $exchange->setFlags($flags);
     $exchange->declareExchange();
     return $exchange;
 }
开发者ID:Jmoati,项目名称:SwarrotBootstrapBundle,代码行数:9,代码来源:PeclAmqpPackageProvider.php

示例3: createExchange

 /**
  * @inheritdoc
  */
 public function createExchange(ChannelInterface $channel, $name, $type = ExchangeInterface::TYPE_DIRECT, $flags = null, array $args = [])
 {
     $delegate = new \AMQPExchange($channel->getDelegate());
     $delegate->setName($name);
     $delegate->setType($type);
     $delegate->setFlags(Exchange::convertToDelegateFlags($flags));
     $delegate->setArguments($args);
     return new Exchange($delegate, $channel);
 }
开发者ID:treehouselabs,项目名称:queue,代码行数:12,代码来源:AmqpFactory.php

示例4: _getExchange

 /**
  * Get transport exchange for current channel.
  * @return AMQPExchange
  */
 protected function _getExchange()
 {
     if (!$this->_exchange) {
         $this->_exchange = new \AMQPExchange($this->_getChannel());
         //设置exchange名称
         $this->_exchange->setName($this->_params['exchange']);
         //设置exchange类型
         $this->_exchange->setType(AMQP_EX_TYPE_DIRECT);
         //设置exchange参数
         $this->_exchange->setFlags(AMQP_DURABLE | AMQP_AUTODELETE);
     }
     return $this->_exchange;
 }
开发者ID:mywin,项目名称:mywin,代码行数:17,代码来源:Rabbitmq.php

示例5: 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;
 }
开发者ID:paulchyrilov,项目名称:zf2-rabbitmq-eventbus-module,代码行数:18,代码来源:EventBusAdapter.php

示例6: setUpAmqp

 /**
  * {@inheritDoc}
  */
 protected function setUpAmqp()
 {
     $this->conn = new \AMQPConnection(['host' => $_SERVER['AMQP_HOST'], 'port' => $_SERVER['AMQP_PORT'], 'login' => $_SERVER['AMQP_USER'], 'password' => $_SERVER['AMQP_PASS'], 'vhost' => $_SERVER['AMQP_VHOST']]);
     $this->conn->connect();
     $channel = new \AMQPChannel($this->conn);
     $exchange = new \AMQPExchange($channel);
     $exchange->setName('event_band.test.exchange');
     $exchange->setFlags(AMQP_AUTODELETE);
     $exchange->setType(AMQP_EX_TYPE_TOPIC);
     $exchange->declareExchange();
     $queue = new \AMQPQueue($channel);
     $queue->setName('event_band.test.event');
     $queue->declareQueue();
     $queue->bind('event_band.test.exchange', 'event.#');
 }
开发者ID:event-band,项目名称:band-transport-amqp-pecl,代码行数:18,代码来源:PeclAmqpDriverTest.php

示例7: setupConnection

 public static function setupConnection(\AMQPConnection $connection, $config)
 {
     $channel = new \AMQPChannel($connection);
     $exchange = new \AMQPExchange($channel);
     $exchange->setName($config['exchange_name']);
     $exchange->setType(AMQP_EX_TYPE_DIRECT);
     $exchange->setFlags(AMQP_DURABLE);
     $exchange->declareExchange();
     $queue = new \AMQPQueue($channel);
     $queue->setName($config['queue_name']);
     $queue->setFlags(AMQP_DURABLE);
     $queue->declareQueue();
     //        $exchange->bind($config['queue_name'], 'gos.websocket.pusher');
     return [$channel, $exchange, $queue];
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:15,代码来源:Utils.php

示例8: exchangeDeclare

 protected function exchangeDeclare()
 {
     if ($this->exchange === null) {
         $this->exchange = new AMQPExchange($this->channel);
     }
     $this->exchange->setName($this->exchangeOptions['name']);
     $this->exchange->setType($this->exchangeOptions['type']);
     $this->exchange->setFlags($this->getFlagsFromOptions());
     $this->exchange->setArguments($this->exchangeOptions['arguments']);
     $this->exchange->declareExchange();
     foreach ($this->exchangeOptions['binding'] as $bindOpt) {
         $this->exchange->bind($bindOpt['name'], $bindOpt['routing-keys']);
     }
     $this->exchangeDeclared = true;
 }
开发者ID:umpirsky,项目名称:ko-worker,代码行数:15,代码来源:Producer.php

示例9: createExchange

 /**
  * {@inheritDoc}
  */
 public function createExchange()
 {
     // Create AMQP connection
     $amqpConnection = new \AMQPConnection(['host' => $this->host, 'port' => $this->port, 'vhost' => $this->vhost, 'login' => $this->login, 'password' => $this->password]);
     $amqpConnection->connect();
     // Create channel
     $channel = new \AMQPChannel($amqpConnection);
     // Create exchange
     $exchange = new \AMQPExchange($channel);
     $exchange->setName($this->exchangeName);
     $exchange->setType($this->exchangeType);
     $exchange->setFlags(AMQP_DURABLE);
     $exchange->declareExchange();
     return $exchange;
 }
开发者ID:Gtvar,项目名称:FivePercent-IntegrationBundle,代码行数:18,代码来源:ConfigExchangeFactory.php

示例10: publish

 /**
  * @param \AMQPEnvelope $envelope
  * @param \AMQPQueue $queue
  * @param string $m
  */
 public function publish($envelope, $queue, $m)
 {
     if ($m instanceof AmqpResp) {
         $m = Json::encode($m->getData());
     } elseif (is_object($m) || is_array($m)) {
         $m = Json::encode($m);
     }
     $chanel = $this->getChanel();
     // Точка доступа
     // Точка обмена
     $exchange = new \AMQPExchange($chanel);
     $exchange->setFlags(AMQP_AUTODELETE | AMQP_DURABLE);
     $attributes = array('correlation_id' => $envelope->getCorrelationId());
     $routingKey = $envelope->getReplyTo();
     if ($exchange->publish($m, $routingKey, AMQP_NOPARAM, $attributes)) {
         $queue->ack($envelope->getDeliveryTag());
     }
 }
开发者ID:andriell,项目名称:yii2-amqp,代码行数:23,代码来源:AmqpConsumer.php

示例11: main

 public static function main()
 {
     self::$pool = new Pool(MAX_CONCURRENCY_JOB, \CALLWorker::class, []);
     $conn_args = (require 'mq.config.php');
     $e_name = 'e_linvo';
     //交换机名
     $q_name = 'q_linvo';
     //队列名
     $k_route = 'key_1';
     //路由key
     //创建连接和channel
     $conn = new AMQPConnection($conn_args);
     if (!$conn->connect()) {
         write_log('mq.hx9999.com 无法连接上');
         return;
     }
     $channel = new AMQPChannel($conn);
     //创建交换机
     $ex = new AMQPExchange($channel);
     $ex->setName($e_name);
     $ex->setType(AMQP_EX_TYPE_DIRECT);
     //direct类型
     $ex->setFlags(AMQP_DURABLE);
     //持久化
     //创建队列
     $q = new AMQPQueue($channel);
     $q->setName($q_name);
     $q->setFlags(AMQP_DURABLE);
     //持久化
     while (True) {
         $q->consume(function ($envelope, $queue) {
             $msg = $envelope->getBody();
             $queue->ack($envelope->getDeliveryTag());
             //手动发送ACK应答
             self::$pool->submit(new Sendsms($msg));
         });
     }
     self::$pool->shutdown();
     $conn->disconnect();
     //睡眠
     sleep(5);
 }
开发者ID:haibrother,项目名称:php-mq-demo,代码行数:42,代码来源:service.php

示例12: send

 public function send($msg)
 {
     $channel = new \AMQPChannel($this->connection);
     $exchange = new \AMQPExchange($channel);
     $exchange->setFlags(AMQP_DURABLE);
     $exchange->setName('exchange2');
     $exchange->setType('direct');
     //$exchange->declare();
     $exchange->declareExchange();
     $queue = new \AMQPQueue($channel);
     $queue->setName('series');
     $queue->setFlags(AMQP_DURABLE | AMQP_AUTODELETE);
     //$queue->declare();
     $queue->declareQueue();
     $queue->bind('exchange2', 'series');
     $channel->startTransaction();
     $message = $exchange->publish(json_encode($msg), 'series', AMQP_MANDATORY, array('content_type' => 'application/json', 'delivery_mode' => 2));
     $channel->commitTransaction();
     if (!$message) {
         throw new \SYSTEM\LOG\ERROR("Error: Message '" . $message . "' was not sent to queue.!");
     }
 }
开发者ID:webcraftmedia,项目名称:system,代码行数:22,代码来源:ConnectionAMQP.php

示例13: set

 /**
  * 入RabbitMQ队列
  * @param [type] $exName    [交换机名]
  * @param [type] $routingKey [路由名]
  * @param [type] $value     [队列的值]
  * @param [type] $dbType     [数据库类型,默认为mysql]
  * 按照此规则生成的默认队列名称为 exName_routeKey_dbType;值为value
  */
 public function set($exName, $routingKey, $value, $dbType = 'mysql')
 {
     //创建交换机,设置交换机名
     $ex = new \AMQPExchange($this->channel);
     $ex->setName($exName);
     $ex->setType(AMQP_EX_TYPE_DIRECT);
     //广播模式
     $ex->setFlags(AMQP_DURABLE);
     //交换器进行持久化,即 RabbitMQ 重启后会自动重建
     // $ex->declareExchange();
     //设置队列名
     $queue = new \AMQPQueue($this->channel);
     $queue->setName($exName . '_' . $routingKey . '_' . $dbType);
     $queue->setFlags(AMQP_DURABLE);
     //队列进行持久化,即 RabbitMQ 重启后会自动重建
     $queue->declareQueue();
     //交换机和路由绑定到队列
     $queue->bind($exName, $routingKey);
     //入队列
     if (is_array($value)) {
         $value = json_encode($value);
     }
     $ex->publish($value, $routingKey, AMQP_NOPARAM, array('delivery_mode' => '2'));
 }
开发者ID:dormscript,项目名称:dataTransfer,代码行数:32,代码来源:RabbitMq.php

示例14: writeRMQ

/**
 * 批量打入v3work_seo_pdrec数据,用于预热本企业推荐产品
 */
function writeRMQ($exchangeName = 'v3www', $router, $data = '')
{
    $cfg = array('host' => '192.168.8.18', 'port' => '5672', 'login' => 'v3work', 'password' => 'gc7232275', 'vhost' => '/');
    if (empty($exchangeName) || empty($data) || empty($cfg)) {
        return false;
    }
    $reTryNum = 3;
    $errMsg = array();
    do {
        try {
            //建立到rmq服务器链接
            $connection = new AMQPConnection($cfg);
            $connection->connect();
            //建立channel对象
            $channel = new AMQPChannel($connection);
            //建立交换机
            $exchange = new AMQPExchange($channel);
            $exchange->setName($exchangeName);
            $exchange->setType(AMQP_EX_TYPE_DIRECT);
            $exchange->setFlags(AMQP_DURABLE);
            $exchange->declare();
            $routingKey = $router;
            //发消息
            $ret = $exchange->publish($data, $routingKey, AMQP_NOPARAM, array('delivery_mode' => '2'));
            //关闭链接
            $connection->disconnect();
            return $ret;
        } catch (Exception $e) {
            $connection->disconnect();
            $errMsg[] = $e->getMessage();
            usleep(5000);
            $reTryNum -= 1;
        }
    } while ($reTryNum);
    return false;
}
开发者ID:tianyunchong,项目名称:php,代码行数:39,代码来源:simrec.php

示例15: AMQPChannel

//交换机名
$q_name = 'q_test5';
//队列名称
$r_key = 'key_test1';
//消息
$message = json_encode(array("HelloWorld"));
//创建channel
$channel = new AMQPChannel($conn);
//注:队列跟exchange 都需要基于channel channel基于connection
$ex = new AMQPExchange($channel);
//新建exchange
$ex->setName($e_name);
//创建exchange的名字
$ex->setType(AMQP_EX_TYPE_DIRECT);
//TPYE DIRECT 添加进绑定key的所有的队列,FANOUT 添加进绑定的所有队列 TOPIC 自定义的规则 . 连接多个队列 #为通配符
$ex->setFlags(AMQP_DURABLE | AMQP_AUTODELETE);
echo "exchange status:" . $ex->declare();
echo "\n";
//创建队列
$q = new AMQPQueue($channel);
//新建队列
//设置队列的名字 如果不存在则自动添加
$q->setName($q_name);
$q->setFlags(AMQP_DURABLE | AMQP_AUTODELETE);
//添加属性 DURABLE持久的 AUTODELEETE没有连接自动删除
echo "queue status:" . $q->declare();
//声明队列
echo "\n";
echo 'queue bind:' . $q->bind($e_name, $r_key);
//将队列绑定到routingKey
echo "\n";
开发者ID:flydement,项目名称:MyTest,代码行数:31,代码来源:producter.php


注:本文中的AMQPExchange::setFlags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。