apache / pulsar-client-python

Apache Pulsar Python client library
https://pulsar.apache.org/
Apache License 2.0
49 stars 38 forks source link

[asyncio] Support creating producer and sending messages #189

Closed BewareMyPower closed 6 months ago

BewareMyPower commented 6 months ago

Master issue: https://github.com/apache/pulsar-client-python/issues/55

Modifications

Introduce a pulsar.asyncio module that includes the asynchronous APIs to work with Python asyncio module.

Example:

async def main():
    client = Client('pulsar://localhost:6650')
    try:
        producer = await client.create_producer('topic')
        msg_id = await producer.send('msg'.encode())
        await producer.close()
    except PulsarException as e:
        error = e.error()
    await client.close()

The creation of Client reuses the same keyword arguments from pulsar.Client but the options for creating producer and sending messages are not added yet.