|
Nov '14 |
3 |
2425 |
0 |
I just do it by reference with https://www.rabbitmq.com/tutorials/tutorial-one-php.html. It seems that
$conn = new AMQPConnection($conn_args);
doesn't work.
Are you getting an error/exception or something?
I just do it by reference with https://www.rabbitmq.com/tutorials/tutorial-one-php.html. It seems that
$conn = new AMQPConnection($conn_args);
doesn't work.
make sure you are requiring vendor autoload?
require BASE_DIR . "/vendor/autoload.php";
I'm not sure if you obfuscated your connection params but AMQPConnection takes 4 params. I prefer to have the Phalcon DI load mine so here is an example:
/**
* register a lazy loaded singleton queue service
*/
$di->setShared('queue', function() use ($config) {
$connection = new \PhpAmqpLib\Connection\AMQPConnection($config->rabbit->host, $config->rabbit->port, $config->rabbit->username,$config->rabbit->password);
return $connection;
});
Then from a plugin or a model or whever you want to create your notice:
$channel = $this->getDi()->getShared('queue')->channel();
/**
*
* name: $queue
* passive: false
* durable: true // the queue will survive server restarts
* exclusive: false // the queue can be accessed in other channels
* auto_delete: false //the queue won't be deleted once the channel is closed.
*/
$channel->queue_declare('my-queue-name', false, true, false, false);
$channel->basic_qos(null, 1, null);
$msg = new \PhpAmqpLib\Message\AMQPMessage('message to be sent', array(
'delivery_mode' => 2, //make messages persistent
)
);
$channel->basic_publish($msg, '', 'my-queue-name');
$channel->close();
No, but its response is 500 internal server error
Are you getting an error/exception or something?
I just do it by reference with https://www.rabbitmq.com/tutorials/tutorial-one-php.html. It seems that
$conn = new AMQPConnection($conn_args);
doesn't work.