rocket-mq-client-thinkphp/example/Producer.php

45 lines
897 B
PHP
Raw Normal View History

2023-07-09 10:12:14 +00:00
<?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);
}
}