How to consume messages from Cloud Pub/Sub with the Messenger component of Symfony and Enqueue adapter?
Asked Answered
S

0

7

Tools I'm using:


My config files:

#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)%'

Sending message / command to a Cloud Pub/Sub queue OK

My message / command CreateStore is properly send to Cloud Pub/Sub like this :

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']
)));

All message/command are in my Cloud Pub/Sub Queue, I can see them and acknowledge them manual via the gcloud Command-Line Tool like this:

gcloud pubsub subscriptions pull enqueue.commands

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


Consuming messages from a Cloud Pub/Sub queue KO

Now I trying to consume my message by running:

bin/console messenger:consume-messages enqueue

The consumer run but nothing is happening.

What I'm missing to consume my messages available on Cloud Pub/Sub?

Sputnik answered 12/10, 2018 at 9:21 Comment(1)
see my comment on related issue github.com/php-enqueue/messenger-adapter/issues/…Rodas

© 2022 - 2024 — McMap. All rights reserved.