#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)%'
我的消息/命令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
现在,我尝试通过运行来消耗消息:
bin/console messenger:consume-messages enqueue
消费者奔走,但什么也没发生。
要使用Cloud Pub / Sub上的可用消息,我缺少什么?