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_sequence_id Return the last sequence id that was published and acknowledged by this producer.
Method producer_name 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
def __init__(self, producer: _pulsar.Producer, schema: pulsar.schema.Schema): (source)

Create the producer. Users should not call this constructor directly. Instead, create the producer via Client.create_producer.

Parameters
producer:_pulsar.ProducerThe underlying Producer object from the C extension.
schema:pulsar.schema.SchemaThe schema of the data that will be sent by this producer.
async def close(self): (source)

Close the producer.

Raises
PulsarException
async def flush(self): (source)

Flush all the messages buffered in the producer asynchronously.

Raises
PulsarException
def last_sequence_id(self): (source)

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.

def producer_name(self): (source)

Return the producer name which could have been assigned by the system or specified by the client

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:AnyThe message payload, whose type should respect the schema defined in Client.create_producer.
properties:dict|
None
A dict of application-defined string properties.
partition_key:str|
None
Sets the partition key for the message routing. A hash of this key is used to determine the message's topic partition.
ordering_key:str|
None
Sets the ordering key for the message routing.
sequence_id:int|
None
Specify a custom sequence id for the message being published.
replication_clusters:List[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.
disable_replication:bool|
None
Do not replicate this message.
event_timestamp:int|
None
Timestamp in millis of the timestamp of event creation
deliver_at:int|
None
Specify the message should not be delivered earlier than the specified timestamp.
deliver_after:timedelta|
None
Specify a delay in timedelta for the delivery of the messages.
Returns
pulsar.MessageIdThe message id that represents the persisted position of the message.
Raises
PulsarException
def topic(self): (source)

Return the topic which producer is publishing to

_producer = (source)

Undocumented

Undocumented