mawdoo3-com /waraqa-amq-integration
此包是waraqa平台的回调API,用于发布文章
dev-master
2024-01-22 11:40 UTC
Requires
- php: ^8.0.2
- gumlet/php-image-resize: 1.9.*
- guzzlehttp/guzzle: ^6.5.3|^7.0.1
- php-amqplib/php-amqplib: 3.6.*
This package is not auto-updated.
Last update: 2024-09-17 13:24:36 UTC
README
此包是waraqa服务的集成SDK,同时它也连接到cloudamqp.com RabbitMQ云基础服务。
要安装此包
composer require mawdoo3com/waraqa-integration
消费者使用:
<?php
use Waraqa\Connection\WAMQPConnect;
use PhpAmqpLib\Message\AMQPMessage;
use Waraqa\Consumer;
class WaraqaIntegration
{
public function execute()
{
$client_id = getenv('CLIENT_ID');//will provided by waraqa admin
$connection_string = getenv('AQMP_CONNECTION');//will provided by waraqa admin
$connection_obj = new WAMQPConnect($connection_string, $client_id);
$connection = $connection_obj->connect();
$consumer = new Consumer();
$consumer->consume($connection, [$this, 'process']);
}
public function process(AMQPMessage $message)
{
//your code goes here, this is the callback function
}
}
生产者使用:
<?php
use Waraqa\Connection\WAMQPConnect;
use Waraqa\Producer;
class WaraqaIntegration
{
public function execute()
{
$client_id = getenv('CLIENT_ID');//will provided by waraqa admin
$connection_string = getenv('AQMP_CONNECTION');//will provided by waraqa admin
$connection_obj = new WAMQPConnect($connection_string, $client_id);
$connection = $connection_obj->connect();
$producer = new Producer();
$producer->produce($connection,'message',[param1,param2,...etc]);
}
}