Skip to content

Message serialization problems #857

Answered by Lancetnik
SirSilver asked this question in Q&A
Discussion options

You must be logged in to vote

@SirSilver @kumaranvpl it's not a bug, it just an incorrect usage

When you are using the single argument as a function annotation, your message body will be serialized as this argument.

As an example:

async def handler(body: int): ...
# waits any int-serializable message like b"1"

In this case your argument name has no matter cuz it is a total message body.

Multiple arguments is a shortcut for JSONs. In this case your message will be unpacked and serailized by various fields. Please, reade this part carefully.

So

async def handler(name: str, id: int): ...
# waits for { "name": "John", "id": 1 }

But in your case you are trying to consume string message, but send a Mapping.

async def handler(

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SirSilver
Comment options

Answer selected by SirSilver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #848 on October 16, 2023 18:53.