You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our product, we need to show the last N messages to users. While using Kafka, we could simply pull messages based on Offset. Is there an equivalent of method or API for Pulsar?
It seems we could only subscribe to a topic and try to move the cursor to some point based on messageId. But it hard to determine which messageId should be used, because messageId is not sequential.
Reacted by Andy Walker, AdrianoG, on-chain and Michel Casabianca
Yes, currently only support reset cursor by time or message ID. Maybe it needs to support reset cursor by messages count(e.g. last 100 messages) in Pulsar and since a message can be a batch message. If we want to reset to precise last 100 messages, This can be an expensive operation since the broker needs to get the message metadata and counting the number of messages.
@terrencehan Regarding MessageId, It could get from the produce.send or consumer.receive. Maybe reader api is more suitable for this case. 1), set reader init MessageId, 2) read N messages. the initial messageId maybe similar to the way how you get kafka Offset.
How? Tried using a Reader with MessageId.latest and it does not receive the latest message already produced. It only receives the first message published after the creation of the reader.
How? Tried using a Reader with MessageId.latest and it does not send the latest message already produced. It only send the first message published after the creation of the reader.
There's an open issue. However a workaround exists: #10483 (comment) . When using a reader you usually also need to configure a rentention policy. The user manual contains details about that.
How? Tried using a Reader with MessageId.latest and it does not send the latest message already produced. It only send the first message published after the creation of the reader.
There's an open issue. However a workaround exists: #10483 (comment) . When using a reader you usually also need to configure a rentention policy. The user manual contains details about that.
Thanks. That is the issue we have but the workaround is effective.
Activity
codelipenghui commentedon Mar 16, 2020
Yes, currently only support reset cursor by time or message ID. Maybe it needs to support reset cursor by messages count(e.g. last 100 messages) in Pulsar and since a message can be a batch message. If we want to reset to precise last 100 messages, This can be an expensive operation since the broker needs to get the message metadata and counting the number of messages.
jiazhai commentedon Mar 16, 2020
@terrencehan Regarding MessageId, It could get from the produce.send or consumer.receive. Maybe reader api is more suitable for this case. 1), set reader init MessageId, 2) read N messages. the initial messageId maybe similar to the way how you get kafka Offset.
carl297r commentedon Mar 2, 2022
Is it possible to consume the last N messages in the special case where N is 1? Ie Just consume the last message that was already produced.
lhotari commentedon Mar 2, 2022
Yes, that is possible.
carl297r commentedon Mar 2, 2022
How? Tried using a Reader with MessageId.latest and it does not receive the latest message already produced. It only receives the first message published after the creation of the reader.
lhotari commentedon Mar 2, 2022
There's an open issue. However a workaround exists: #10483 (comment) . When using a reader you usually also need to configure a rentention policy. The user manual contains details about that.
carl297r commentedon Mar 2, 2022
Thanks. That is the issue we have but the workaround is effective.
tisonkun commentedon Mar 11, 2023
Closed as answered.