Skip to content

publish_message

faststream.cli.main.publish_message async #

publish_message(app_obj: FastStream, extra: Any) -> Any
Source code in faststream/cli/main.py
async def publish_message(app_obj: FastStream, extra: Any) -> Any:
    try:
        if await app_obj.broker.connect():  # type: ignore[union-attr]
            result = await app_obj.broker.publish(**extra)  # type: ignore[union-attr]
            return result
        else:
            raise ValueError("Failed to connect to the broker.")
    except Exception as e:
        typer.echo(f"Error when broker was publishing: {e}")
        sys.exit(1)