Skip to content
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

[Messenger] [Redis] Can not consume messages published by third party in Redis #42072

Open
welcoMattic opened this issue Jul 12, 2021 · 0 comments
Open

Comments

@welcoMattic
Copy link
Contributor

@welcoMattic welcoMattic commented Jul 12, 2021

Symfony version(s) affected: 5.2

Description
I try to consume messages from a Redis Stream which are published by a third party, but messages do not follow the expected structure from the Redis Bridge.

Accordingly to the code https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php#L398-L408

Messages have to be structured like:

{
    "message": {
        "body": {},
        "headers": []
    }
}

However, my messages doesn't look like this, but more like:

{
    "field1": "value1",
    "field2": "value2"
}

How to reproduce
Use Redis Insight to push a message like

{
    "field1": "value1",
    "field2": "value2"
}

into a Stream, then consume this stream with symfony/redis-messenger.

Catch this error:

messenger:consume [-l|--limit LIMIT] [-f|--failure-limit FAILURE-LIMIT] [-m|--memory-limit MEMORY-LIMIT] [-t|--time-limit TIME-LIMIT] [--sleep SLEEP] [-b|--bus BUS] [--] [<receivers>...]


 [OK] Consuming messages from transports "catalog_import".

 // The worker will automatically exit once it has exceeded 128M of memory or
 // received a stop signal via the messenger:stop-workers command.

 // Quit the worker with CONTROL-C.

 // Re-run the command with a -vv option to see logs about consumed messages.


In Connection.php line 399:

  Notice: Undefined index: message


messenger:consume [-l|--limit LIMIT] [-f|--failure-limit FAILURE-LIMIT] [-m|--memory-limit MEMORY-LIMIT] [-t|--time-limit TIME-LIMIT] [--sleep SLEEP] [-b|--bus BUS] [--] [<receivers>...]

Possible Solution
A possible solution could be to determine the existence of the key message in $message array, and if not exists, return the raw message, which could be decoded by a custom serializer.

cc @lyrixx @sroze

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants