コード例 #1
0
ファイル: MQ.php プロジェクト: tresemece/monte
 public static function send_message($qq, $options)
 {
     $connection = new \PhpAmqpLib\Connection\AMQPConnection(static::get_conf()->host, static::get_conf()->port, static::get_conf()->user, static::get_conf()->pasw);
     $channel = $connection->channel();
     $channel->queue_declare($qq, false, true, false, false);
     $msg = new \PhpAmqpLib\Message\AMQPMessage(json_encode($options), array("content_type" => "json"));
     $channel->basic_publish($msg, '', $qq);
     $channel->close();
     $connection->close();
 }
コード例 #2
0
ファイル: RabbitMQProvider.php プロジェクト: DBezemer/server
 public function create($queueName)
 {
     // establish connection to RabbitMQ
     $connection = new PhpAmqpLib\Connection\AMQPConnection($this->MQserver, $this->port, $this->username, $this->password);
     $channel = $connection->channel();
     // durable = true to make sure that RabbitMQ will never lose our queue (if RabbitMQ server stops)
     // exclusive=false to be accessed by other connections
     // auto-delete the queue after 12hours (43200000 ms)
     $channel->queue_declare($queueName, false, true, false, false, false, new PhpAmqpLib\Wire\AMQPTable(array("x-expires" => (int) $this->timeout)));
     // close used resources
     KalturaLog::info("Queue [{$queueName}] created.");
     $channel->close();
     $connection->close();
 }