mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 08:03:30 +02:00
Remove namespaces to allow this transport to be called from anonymous function
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user