class documentation
The Pulsar message producer, used to publish messages on a topic.
| Method | __init__ |
Create the producer. Users should not call this constructor directly. Instead, create the producer via Client.create_producer. |
| Async Method | close |
Close the producer. |
| Async Method | flush |
Flush all the messages buffered in the producer asynchronously. |
| Method | last |
Return the last sequence id that was published and acknowledged by this producer. |
| Method | producer |
Return the producer name which could have been assigned by the system or specified by the client |
| Async Method | send |
Send a message asynchronously. |
| Method | topic |
Return the topic which producer is publishing to |
| Instance Variable | _producer |
Undocumented |
| Instance Variable | _schema |
Undocumented |
Create the producer.
Users should not call this constructor directly. Instead, create the
producer via Client.create_producer.
| Parameters | |
producer:_pulsar.Producer | The underlying Producer object from the C extension. |
schema:pulsar.schema.Schema | The schema of the data that will be sent by this producer. |
Return the last sequence id that was published and acknowledged by this producer.
The sequence id can be either automatically assigned or custom set on the message. After recreating a producer with the same name, this will return the sequence id of the last message that was published in the previous session, or -1 if no message was ever published.
async def send(self, content:
Any, properties: dict | None = None, partition_key: str | None = None, ordering_key: str | None = None, sequence_id: int | None = None, replication_clusters: list[ str] | None = None, disable_replication: bool | None = None, event_timestamp: int | None = None, deliver_at: int | None = None, deliver_after: timedelta | None = None) -> pulsar.MessageId:
(source)
¶
Send a message asynchronously.
| Parameters | |
content:Any | The message payload, whose type should respect the schema defined in
Client.create_producer. |
properties:dict|None | A dict of application-defined string properties. |
partitionNone | Sets the partition key for the message routing. A hash of this key is used to determine the message's topic partition. |
orderingNone | Sets the ordering key for the message routing. |
sequenceNone | Specify a custom sequence id for the message being published. |
replicationList[str] |None | Override namespace replication clusters. Note that it is the caller's responsibility to provide valid cluster names and that all clusters have been previously configured as topics. Given an empty list, the message will replicate per the namespace configuration. |
disableNone | Do not replicate this message. |
eventNone | Timestamp in millis of the timestamp of event creation |
deliverNone | Specify the message should not be delivered earlier than the specified timestamp. |
deliverNone | Specify a delay in timedelta for the delivery of the messages. |
| Returns | |
pulsar.MessageId | The message id that represents the persisted position of the message. |
| Raises | |
PulsarException | |