45 lines
897 B
PHP
45 lines
897 B
PHP
<?php
|
|
|
|
namespace example;
|
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
use tm\xls\rocketMq\thinkphp\Client;
|
|
use tm\xls\rocketMq\thinkphp\connection\Connection;
|
|
|
|
class Producer
|
|
{
|
|
/**
|
|
* 单个
|
|
*
|
|
* @return void
|
|
* @throws GuzzleException
|
|
*/
|
|
public function demo()
|
|
{
|
|
$data = [
|
|
|
|
"body" => [], //消息
|
|
"tag" => "string", //tag
|
|
"topic" => "string" // 主题
|
|
];
|
|
Client::producer(new Connection())->handle($data);
|
|
}
|
|
|
|
/**
|
|
* 批量
|
|
*
|
|
* @return void
|
|
* @throws GuzzleException
|
|
*/
|
|
public function demoBatch()
|
|
{
|
|
$data = [
|
|
[
|
|
"body" => [], //消息
|
|
"tag" => "string", //tag
|
|
"topic" => "string" // 主题
|
|
]
|
|
];
|
|
Client::producer(new Connection())->handleWithBatch($data);
|
|
}
|
|
} |