Remove namespaces to allow this transport to be called from anonymous function

This commit is contained in:
Guillaume COEUGNET
2016-03-30 16:01:16 +02:00
parent 5d21bf9a55
commit 3a4db5194c
+3 -5
View File
@@ -1,6 +1,4 @@
require_once "/usr/share/php/PhpAmqpLib/autoload.php"; require_once "./lib/PhpAmqpLib/autoload.php";
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
// Configurations // Configurations
$host = $opts["host"]; $host = $opts["host"];
@@ -11,7 +9,7 @@ $vhost = $opts["vhost"];
$exchange = "canopsis.events"; $exchange = "canopsis.events";
// Connection // Connection
$conn = new AMQPConnection($host, $port, $user, $pass, $vhost); $conn = new PhpAmqpLib\Connection\AMQPConnection($host, $port, $user, $pass, $vhost);
$ch = $conn->channel(); $ch = $conn->channel();
// Declare exchange (if not exist) // Declare exchange (if not exist)
@@ -51,7 +49,7 @@ else
$msg_rk = $msg_body['connector'].".".$msg_body['connector_name'].".".$msg_body['event_type'].".".$msg_body['source_type'].".".$msg_body['component']; $msg_rk = $msg_body['connector'].".".$msg_body['connector_name'].".".$msg_body['event_type'].".".$msg_body['source_type'].".".$msg_body['component'];
// Publish Event // Publish Event
$msg = new AMQPMessage($msg_raw, array('content_type' => 'application/json', 'delivery_mode' => 2)); $msg = new PhpAmqpLib\Message\AMQPMessage($msg_raw, array('content_type' => 'application/json', 'delivery_mode' => 2));
$ch->basic_publish($msg, $exchange, $msg_rk); $ch->basic_publish($msg, $exchange, $msg_rk);
// Close connection // Close connection