The "Peek nth message on a topic subscription" functionality in Apache Pulsar allows you to retrieve a specific message from a subscription without acknowledging it, meaning the message remains in the subscription for future consumption. According to the
Pulsar documentation, this API returns a binary byte stream containing the message data, which clients need to parse based on the message metadata provided in the response headers.
If there are no messages available to be consumed in the subscription, the API will not return a message. Instead, it may return an error indicating that the message position does not exist. The API is designed to return a single message at the specified position, not multiple messages.
Here is an example of how you might use the REST API to peek a message:
curl --location --request GET 'http://localhost:8080/admin/v2/persistent/public/default/my-topic/subscription/my-sub/position/1'
This request attempts to peek the first message in the subscription
my-sub
for the topic
my-topic
. If successful, the response will contain the message data in a binary format.
Would you like more details on how to handle the response or any specific use case?
Sources:
-
Pulsar documentation 👍 0 button 👎 0 button 💡
Hint: Mention @runllm in the thread for followups.