apache / apache/pulsar

[Pulsar Websocket] Consumer message can't be acknowleaged successfully after toByteArray & fromByteArray

Open
#12,059 6 comments 0 reactions 0 assignees View on GitHub
lifecycle/stale type/bug
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 14h
Merged PRs (30d)
160

Description

Case 1. After receiving the message from Pulsar consumer, just calling the consumer.acknowledge() immediately, this message can be acknowledged successfully. Here's the code
```
consumer.receiveAsync().thenAccept(msg -> {
consumer.acknowledge(msg.getMessageId());
....
}
```

Case 2. If I calling the toByteArray & fromByteArrayWithTopic functions, the message just can't be acknowledged successfully.
```
consumer.receiveAsync().thenAccept(msg -> {
MessageId msgId = MessageId.fromByteArrayWithTopic(msg.getMessageId().toByteArray(), topic.toString());
consumer.acknowledgeAsync(msgId);
....
}
```

Case 3. If I calling the toByteArray & fromByteArray functions, the message just still can't be acknowledged successfully.
```
consumer.receiveAsync().thenAccept(msg -> {
MessageId msgId = MessageId.fromByteArray(msg.getMessageId().toByteArray());
consumer.acknowledgeAsync(msgId);
....
}
```

Case 4. Still failed
```
consumer.receiveAsync().thenAccept(msg -> {
String messageId = Base64.getEncoder().encodeToString(msg.getMessageId().toByteArray());
MessageId msgId = MessageId.fromByteArrayWithTopic(Base64.getDecoder().decode(messageId), topic.toString());
consumer.acknowledgeAsync(msgId);
....
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the receiveAsync, MessageId.toByteArray/fromByteArray and fromByteArrayWithTopic, and acknowledgeAsync paths shown in the report. Compare them with the direct acknowledge case and determine why the serialized MessageId is not accepted. Done means the serialized and deserialized IDs acknowledge successfully in the reported cases, with regression coverage if the relevant test location is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.