AsyncConfluentFastProducer
faststream.confluent.producer.AsyncConfluentFastProducer #
AsyncConfluentFastProducer(producer: AsyncConfluentProducer)
A class to represent a fast Kafka producer.
METHOD | DESCRIPTION |
---|---|
publish | Publishes a message to a Kafka topic. |
stop | Stops the Kafka producer. |
publish_batch | Publishes a batch of messages to a Kafka topic. |
Initialize the class.
PARAMETER | DESCRIPTION |
---|---|
producer | An instance of AsyncConfluentProducer. TYPE: |
Source code in faststream/confluent/producer.py
publish async
#
publish(message: SendableMessage, topic: str, key: Optional[bytes] = None, partition: Optional[int] = None, timestamp_ms: Optional[int] = None, headers: Optional[Dict[str, str]] = None, correlation_id: Optional[str] = None, *, reply_to: str = '') -> None
Publish a message to a topic.
PARAMETER | DESCRIPTION |
---|---|
message | The message to be published. TYPE: |
topic | The topic to publish the message to. TYPE: |
key | The key associated with the message. |
partition | The partition to which the message should be sent. |
timestamp_ms | The timestamp of the message in milliseconds. |
headers | Additional headers to be included with the message. |
correlation_id | The correlation ID of the message. |
reply_to | The topic to which the reply should be sent. TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | None |
RAISES | DESCRIPTION |
---|---|
AssertionError | If the broker is not connected. |
Source code in faststream/confluent/producer.py
publish_batch async
#
publish_batch(*msgs: SendableMessage, topic: str, partition: Optional[int] = None, timestamp_ms: Optional[int] = None, headers: Optional[Dict[str, str]] = None) -> None
Publish a batch of messages to a topic.
PARAMETER | DESCRIPTION |
---|---|
*msgs | Variable length argument list of messages to be sent. TYPE: |
topic | The topic to which the messages should be published. TYPE: |
partition | The partition to which the messages should be sent. Defaults to None. |
timestamp_ms | The timestamp to be associated with the messages. Defaults to None. |
headers | Additional headers to be included with the messages. Defaults to None. |
RETURNS | DESCRIPTION |
---|---|
None | None |
RAISES | DESCRIPTION |
---|---|
AssertionError | If the broker is not connected. |