Skip to content

MQTTResponse

faststream.mqtt.response.MQTTResponse #

MQTTResponse(
    body: SendableMessage,
    *,
    headers: dict[str, str] | None = None,
    correlation_id: str | None = None,
    qos: QoS = AT_MOST_ONCE,
    retain: bool = False,
)

Bases: Response

Source code in faststream/mqtt/response.py
def __init__(
    self,
    body: "SendableMessage",
    *,
    headers: dict[str, str] | None = None,
    correlation_id: str | None = None,
    qos: QoS = QoS.AT_MOST_ONCE,
    retain: bool = False,
) -> None:
    super().__init__(body=body, headers=headers, correlation_id=correlation_id)
    self.qos = qos
    self.retain = retain

qos instance-attribute #

qos = qos

retain instance-attribute #

retain = retain

body instance-attribute #

body = body

headers instance-attribute #

headers = headers or {}

correlation_id instance-attribute #

correlation_id = correlation_id

as_publish_command #

as_publish_command() -> MQTTPublishCommand
Source code in faststream/mqtt/response.py
@override
def as_publish_command(self) -> "MQTTPublishCommand":
    return MQTTPublishCommand(
        message=self.body,
        headers=self.headers,
        correlation_id=self.correlation_id,
        _publish_type=PublishType.PUBLISH,
        topic="",
        qos=self.qos,
        retain=self.retain,
    )

get_publish_key #

get_publish_key() -> Any | None

Get the key for publishing this message.

Override this method in subclasses to provide broker-specific keys. Default implementation returns None (no key).

RETURNS DESCRIPTION
Any | None

The key for publishing, or None if this Response type doesn't use keys.

Source code in faststream/response/response.py
def get_publish_key(self) -> Any | None:
    """Get the key for publishing this message.

    Override this method in subclasses to provide broker-specific keys.
    Default implementation returns None (no key).

    Returns:
        The key for publishing, or None if this Response type doesn't use keys.
    """
    return None