$user = new User('Sasha', 'kalendarev'); $user->setPswd(777); //print serialize($user); // print_r( get_loaded_extensions() ); $cnn = new AMQPConnection(['port' => 5677]); // $cnn = new AMQPConnection(); if (!$cnn) { die("AMQP connection fail"); } echo "------ connect ... --------\n"; $ret = $cnn->connect(); echo "------ open Channel --------\n"; $ch = new AMQPChannel($cnn); echo "------ open Ok --------\n"; $ex = new AMQPExchange($ch); echo "------ exchange Ok --------\n"; // $cnn->disconnect(AMQP_NOPARAM); $ex->setName('test_e'); define('PLAIN', 'text/plain'); define('JSON', 'text/json'); $ex->setArgument('content_type', PLAIN); $ex->setArgument('user_id', 'guest'); $ex->setArgument('timestamp', time()); $headers = ['sss' => 'asd', 'xxx' => 321]; echo "------ publish ... --------\n"; $ex->publish("*******", 'kkk', AMQP::NOPARAM, ['content_type' => 'text/xml']); // $testExchange->publish($msg, 'scan', AMQP_NOPARAM, // ['headers' => ['x-model'=>'object', 'x-type' => 123]]); //var_dump($ex); echo "------ publish Ok --------\n"; $cnn->disconnect();
/** * @param $key * @param $value * * @return bool */ public function setArgument($key, $value) { return $this->rawExchange->setArgument($key, $value); }
/** * @inheritdoc */ public function setArgument(string $key, $value) { $this->exchange->setArgument($key, $value); }