fhteam/xenforo-amqp

用于XenForo插件的AMQP库

v1.0.0 2015-03-04 08:53 UTC

This package is not auto-updated.

Last update: 2024-09-28 16:31:11 UTC


README

为XenForo提供AMQP客户端库,以便使用RabbitMQ等服务器

安装

请注意,包名已更改为fhteam/xenforo-amqp。旧名称仍然可以使用,但将不再维护。

库遵循PSR4规范,因此安装方式与其他XenForo插件略有不同

因此,要使用此库,您可以直接将脚本包含到您的源中,或者执行以下操作

配置

将以下行放在您的library/config.php文件末尾

//============ AMQP connector settings ============
$config['amqp'] = array(
    'host' => '192.168.1.1.1',          // The host where your AMPQ-compatible server runs
    'port' => '5672',                   // Port, your server runs on
    'user' => 'user',                   // Authentication user name 
    'password' => 'password',           // Authentication password
    'queues' => array(                  // Queues configuration
        'auth_ban' => array(            // The name of the queue
            'queue_flags' => array(     // Queue flags.
                'durable' => true,      // 'durable' means the queue will survice server reboot
            ), 
        ),
    ),
);

用法

  • 创建管理器实例
$manager = new \Forumhouse\XenForoAmqp\QueueManager();
  • 将消息推送到队列
$manager->pushMessage(
    'my_queue_name',                // The name of the queue. Must be in configuration file (see above)
    array('data' => 'test_data'),   // The data to send to the queue. Will be json_encode'd if array is provided
    array('delivery_mode' => 2)     // Message properties. 'delivery_mode' => 2 makes message persistent
);