1
0
mirror of synced 2024-11-21 12:36:05 +03:00
Beanstalkd transport for symfony messenger
Go to file
2023-10-03 16:34:46 +03:00
.github/workflows update dependencies 2023-10-03 16:00:49 +03:00
Storage Lock storage for not_send_if_exists option 2023-10-02 12:41:35 +03:00
Tests/Transport Lock storage for not_send_if_exists option 2023-10-02 12:41:35 +03:00
Transport Lock storage for not_send_if_exists option 2023-10-02 12:41:35 +03:00
.editorconfig Symfony benstalkd messenger (#1) 2021-02-02 11:59:25 +03:00
.gitignore Symfony benstalkd messenger (#1) 2021-02-02 11:59:25 +03:00
composer.json update dependencies 2023-10-03 16:00:49 +03:00
LICENSE Initial commit 2021-01-28 17:17:22 +03:00
phpcs.xml Symfony benstalkd messenger (#1) 2021-02-02 11:59:25 +03:00
phpmd.xml Symfony benstalkd messenger (#1) 2021-02-02 11:59:25 +03:00
phpunit.xml.dist Symfony benstalkd messenger (#1) 2021-02-02 11:59:25 +03:00
README.md Lock storage for not_send_if_exists option 2023-10-02 12:41:35 +03:00

Build Status Coverage Latest stable PHP from Packagist

Symfony beanstalkd messenger

Beanstalkd transport for symfony messenger

Installation

composer require retailcrm/symfony-beanstalkd-messenger

Usage

  • in the .env config file add the connection credentials:

MESSENGER_TRANSPORT_DSN=beanstalkd://localhost:11300

  • create your messages and message handlers (about messages)

  • configure messenger in config/packages/messenger.yml, for example:

framework:
    messenger:
        transports:
            async:
                dsn: "%env(MESSENGER_TRANSPORT_DSN)%"
                options:
                    queue_name: async
        routing:
            'App\Message\MyMessage': async
  • add transport factory in config/services.yml
services:
# ...
    RetailCrm\Messenger\Beanstalkd\Transport\BeanstalkTransportFactory:
        tags: [messenger.transport_factory]

Allowed transport options

  • tube_name - tube name in beanstalkd

  • timeout - timeout for receiving jobs from tube. Default - 0

  • ttr - ttr value for jobs. Default - 60

  • not_send_if_exists - do not send a job to the queue only if such a job is already exist. Default - false

All options are optional, if tube_name not specified will be used default queue default.

The not_send_if_exists option will only work if lock storage is specified. To do this, you need to customize the BeanstalkTransportFactory by adding a call to the setLockStorage method

class MyBeanstalkTransportFactory extends BeanstalkTransportFactory
//...
public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
{
    return new BeanstalkTransport(
        Connection::fromDsn($dsn, $options)->setLockStorage($this->lockStorage),
        $serializer
    );
}
//...

and add your custom transport factory in config/services.yml

services:
# ...
    App\Messenger\Custom\MyBeanstalkTransportFactory:
        tags: [messenger.transport_factory]

Your lock storage class must implement RetailCrm\Messenger\Beanstalkd\Storage\LockStorageInterface.