Create Subscription and Peek at Messages with pulsarctl

Throughout the course we consume messages using peek in a subscription from the UI. If you don’t have access to the UI that’s ok! We can also create a subscription and peek at messages using pulsarctl.

To create a subscription on a topic that starts at the earliest message available:

pulsarctl subscriptions create streamnativeaws1/developer/sentimentoutput1 mysubscription --messageId earliest

To peek at messages in the subscription (must use the partition, by default topics are created as a partitioned topic with a single partition):

pulsarctl subscriptions peek streamnativeaws1/developer/sentimentoutput1-partition-0 mysubscription

Use count to specify the number of messages to view:

pulsarctl subscriptions peek streamnativeaws1/developer/sentimentoutput1-partition-0 mysubscription --count 3

To move the subscription cursor forward to skip all existing messages, use skip all:

pulsarctl subscriptions skip --all streamnativeaws1/developer/sentimentoutput1-partition-0 mysubscription