Skip to content
Discussion options

You must be logged in to vote

And yes, we can fallback to raw JSON. Exactly for compatibility with external not-FastStream systems:

from dataclasses import dataclass

from faststream import FastStream, Logger
from faststream.redis import RedisBroker

broker = RedisBroker("redis://localhost:6379")
app = FastStream(broker)

@dataclass
class User:
    id: str
    name: str

@broker.subscriber("test")
async def test(user: User, logger: Logger) -> None:
    logger.info(user)

@app.after_startup
async def after_startup() -> None:
    await broker.publish(User(id="1", name="John"), "test")

    # Raw Redis publishing
    await broker._connection.publish("test", b'{"id": "1", "name": "John"}')
2026-06-05 19:32:32,837 INFO    …

Replies: 5 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@Lancetnik
Comment options

@Lancetnik
Comment options

Answer selected by Lancetnik
@pbonneaudiabolocom
Comment options

@pbonneaudiabolocom
Comment options

@Lancetnik
Comment options

@Lancetnik
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants