Skip to content

Instantly share code, notes, and snippets.

@skyrocknroll
Created February 25, 2019 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyrocknroll/d33c4a9a827d3a6afa2d08608dc0aa1e to your computer and use it in GitHub Desktop.
Save skyrocknroll/d33c4a9a827d3a6afa2d08608dc0aa1e to your computer and use it in GitHub Desktop.
[apache pulsar] #python #client #seek #begining
import pulsar
from pulsar import MessageId
client = pulsar.Client('pulsar://pulsar.stage.x.com:6650',)
consumer = client.subscribe('persistent://public/default/my-topic-3', 'test-sub5',)
consumer.seek(pulsar.MessageId.earliest)
#consumer.seek(pulsar.MessageId.latest)
while True:
msg = consumer.receive()
print("Received message '{}' id='{}'".format(msg.data(), msg.message_id()))
consumer.acknowledge(msg)
client.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment