8000 Issue with Messenger config and persistent messages · Issue #28885 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Issue with Messenger config and persistent messages #28885
Closed
@konradja100

Description

@konradja100

Symfony version: 4.1.6

Hi, our company is struggling with some messenger configuration problem. We are using messenger component (symfony/amqp-pack included) andRabbitMQ, and everything is working fine, but we want to send messages as persistent - is there some way to setup this configuration by default? Our solution is simple, we wrote custom message transport, and we override sended headers in pusblish method from Connection class:

/**
     * @throws \AMQPException
     */
    public function publish(string $body, array $headers = array()): void
    {
        if ($this->debug && $this->shouldSetup()) {
            $this->setup();
        }

        $this->exchange()->publish($body, null, AMQP_NOPARAM, array('delivery_mode' => 2, 'headers' => $headers));
    }

configuration example:

# services.yaml
App\Service\Messenger\PAmqpTransport\PAmqpTransportFactory:
        tags: [messenger.transport_factory]
        bind:
            $encoder: '@App\Service\Messenger\PAmqpTransport\Serializer'
            $decoder: '@App\Service\Messenger\PAmqpTransport\Serializer'
            $debug: false

# messenger.yaml
 doctrine: 'pamqp://%env(RABBITMQ_USER)%:%env(RABBITMQ_PASS)%@%env(RABBITMQ_HOST)%:%env(RABBITMQ_PORT)%/%2f/doctrine'

We need to send 'delivery_mode' => 2, so Rabbit will keep messages persistent, shouldn't be this option possible to setup in configuration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0