Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] RedisTransport can not use both DSN and preconfigured parameters #39834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
edefimov opened this issue Jan 14, 2021 · 1 comment · Fixed by #39967
Closed

[Messenger] RedisTransport can not use both DSN and preconfigured parameters #39834

edefimov opened this issue Jan 14, 2021 · 1 comment · Fixed by #39967

Comments

@edefimov
Copy link
Contributor

edefimov commented Jan 14, 2021

Symfony version(s) affected: >=5.1.0

Description
Trying to configure redis transport in messenger component via both framework bundle configuration framework.messenger.transports.*.options and query parameters in DSN leads to drop of options defined in framework.messenger.transports.*.options.

How to reproduce

  1. Configure messenger bundle as follows:
framework:
    messenger:
        transports:
            tasks:
                dsn: '%env(APP_REDIS_DSN)%'
                options:
                    stream: my.tasks
                    group: app
                    consumer: app
                    delete_after_ack: true
  1. Define env variable APP_REDIS_DSN with query string
APP_REDIS_DSN=redis://localhost?dbindex=2
  1. Start a consumer
bin/console messenger:consume tasks
  1. As a result only dbindex=2 will be passed into redis Connection. Parameters from framework.messenger.transports.tasks.options are lost

Possible Solution
Replace this line with

parse_str($parsedUrl['query'], $queryOptions);
$redisOptions += $queryOptions;

Additional context

@Kleinast
Copy link

I have the same problem, it seem consumer, group and stream are lost because they are not query params in the DSN.
parse_str completely override $redisOptions

nicolas-grekas added a commit that referenced this issue Jan 26, 2021
This PR was submitted for the 5.1 branch but it was merged into the 4.4 branch instead.

Discussion
----------

[Messenger] fix redis messenger options with dsn

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39834
| License       | MIT

This will fix the fact that you can use framework.messenger.transports.*.options to complete/default your redis configuration

Commits
-------

a0e7bf4 fix redis messenger options with dsn
@xabbuh xabbuh closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants