The preferred method of installation is via Composer:
composer require snortlin/google-pubsub-messenger
# config/services.yaml
services:
Snortlin\GooglePubsubMessenger\Transport\GpsTransportFactory:
tags: [ messenger.transport_factory ]
Create a connection based on the DSN and options:
framework:
messenger:
transports:
google-pubsub:
dsn: 'gps://default?topic=topic_name&subscription=subscription_name&key=base64_key'
topic
: Topic namesubscription
: Subscription namekey
: GPS key JSON formatpull_max_messages
: Limit the amount of messages pulled; default=0 (GPC default => 1000)pull_ack_deadline
: The new ack deadline pulled messages; default=0 (GPC default => 10)redelivery_ack_deadline
: Default ack deadline on redelivered messages, default=0
use Snortlin\GooglePubsubMessenger\Transport\Stamp\OrderingKeyStamp
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\MessageBusInterface;
public function index(MessageBusInterface $bus)
{
$bus->dispatch(new MyMessage('...'), [
new OrderingKeyStamp('my_ordering_key'),
]);
// ...
}