Skip to content

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

Closed
@welcoMattic

Description

@welcoMattic

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions