apache / pulsar-client-node

Apache Pulsar NodeJS Client
https://pulsar.apache.org/
Apache License 2.0
148 stars 86 forks source link

Cannot acknowledge message with deserialized message ID #400

Open adam987 opened 1 day ago

adam987 commented 1 day ago

pulsar-client version: 1.12.0 Pulsar version: 4.0.0

We are creating a Pulsar client service that should enable message acknowledgment with a previously serialized message ID.

During our tests:

  1. No error is thrown during ID deserialization (calling toString on the deserialized message ID also returns a valid value);
  2. No error is thrown during message acknowledgment using acknowledgeId method;
  3. The message that should be acknowledged after the process isn't marked to delete by Pulsar and is received again after resubscription when we use the deserialized message ID.

This makes the deserialized message ID unusable for acknowledging the message. When we use message ID retrieved directly from a received message (without serialization/deserialization) acknowledgment by ID works correctly.

Below is a short version of the code that doesn't seem to work even though no error is thrown consumer.acknowledgeId(MessageId.deserialize(message.getMessageId().serialize()))

Some data (maybe a topic) is probably lost during serialization/deserialization, making the deserialized message ID useless. However, the fact that the acknowledgeId method returns no error seems strange.

Expected behavior: The deserialized message ID should enable acknowledging a message.

I'm also attaching a link to the repo with the error reproduction https://github.com/adam987/pulsar-message-id-deserialization