0

我遵循了 RPC 命令的文档。https://php-enqueue.github.io/client/rpc_call/实际上该页面没有解释如何处理它,所以我不确定这是否正确。当我运行此代码时,我收到此错误:

致命错误:未捕获的 Enqueue\Rpc\TimeoutException:在未收到回复消息的情况下达到 Rpc 调用超时。

这是一个错误吗?我的代码有问题吗?

<?php
require 'vendor/autoload.php';

use Enqueue\Consumption\Result;
use Enqueue\SimpleClient\SimpleClient;

$client = new SimpleClient([
    'transport' => [
        'dsn' => 'file://',
        'path' => __DIR__ . DIRECTORY_SEPARATOR . 'tmp',
    ],
    'client' => [
    ]
]);

$client->setupBroker();

$client->bindCommand('testCommand', static function($message, $context) {
    return Result::reply(
        $context->createMessage('RESPONSE!')
    );
}, null);

$reply = $client->sendCommand('testCommand', 'message data', true);
var_dump($reply->receive(5000)->getBody());
4

0 回答 0