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(); }
public function send($queueName, $data) { // establish connection to RabbitMQ $connection = new PhpAmqpLib\Connection\AMQPConnection($this->MQserver, $this->port, $this->username, $this->password); $channel = $connection->channel(); //function assumes queue exists $msg = new PhpAmqpLib\Message\AMQPMessage($data, array('delivery_mode' => 2)); $channel->basic_publish($msg, '', $queueName); KalturaLog::info("Message [{$data}] was sent to [{$queueName}]."); }