如何使用Symfony and Enqueue适配器的Messenger组件使用来自Cloud Pub / Sub的消息?

时间:2018-10-12 09:21:31

标签: php symfony google-cloud-pubsub symfony-messenger enqueue

我正在使用的工具:


我的配置文件:

#service.yaml

framework:
    messenger:
        transports:
            default: 'amqp://guest:guest@localhost:5672/%2f/messages'
            enqueue: 'enqueue://gps'
        default_bus: messenger.bus.commands
        buses:
            messenger.bus.commands: ~
            messenger.bus.events: ~
        routing:
            # Route your messages to the transports
            'App\Message\Command\Store\CreateStore': enqueue

#enqueue.yaml

enqueue:
    transport:
        default: 'gps'
        gps:
            projectId: '%env(GOOGLE_PROJECT_ID)%'
            keyFilePath: '%env(GOOGLE_APPLICATION_CREDENTIALS)%'

将消息/命令发送到Cloud Pub / Sub队列确定

我的消息/命令CreateStore已正确发送到Cloud Pub / Sub,如下所示:

use App\Message\Command\Store\CreateStore;
use Enqueue\MessengerAdapter\EnvelopeItem\TransportConfiguration;

$command = new CreateStore();
$this->commandBus->dispatch((new Envelope($command))->with(new 
TransportConfiguration(
    ['topic' => 'enqueue.commands']
)));

所有消息/命令都在我的Cloud Pub / Sub队列中,我可以看到它们并通过gcloud命令行工具手动确认它们,如下所示:

gcloud pubsub subscriptions pull enqueue.commands

gcloud pubsub subscriptions pull enqueue.commands --auto-ack


从Cloud Pub / Sub队列KO消费消息

现在,我尝试通过运行来消耗消息:

bin/console messenger:consume-messages enqueue

消费者奔走,但什么也没发生。

要使用Cloud Pub / Sub上的可用消息,我缺少什么?

0 个答案:

没有答案