leizhiyuan opened a new pull request, #1467:
URL: https://github.com/apache/rocketmq-clients/pull/1467

   ### Which Issue(s) This PR Fixes
   
   Fixes #1465
   
   ### Brief Description
   
   `SimpleConsumer.Ack` (also used by `LiteSimpleConsumer`) and 
`PushConsumer.Ack` returned `nil` when the server answered with a non-OK 
status, so a failed ack (e.g. invalid or expired receipt handle) looked 
successful.
   
   Both now return `*ErrRpcStatus{Code, Message}` for a non-OK status, the same 
as `ChangeInvisibleDuration` and `endTransaction` (#1271). Java throws the 
`ClientException` of the status in `SimpleConsumerImpl#ack0`. The ACK hook is 
still marked as `ERROR` in that case; transport errors are returned as before.
   
   The internal ack of `PushConsumer` (`defaultProcessQueue#ackMessage0`) calls 
`ack0` and checks the status itself, so it is not changed.
   
   ### How Did You Test This Change?
   
   **Unit tests** (new `ack_test.go`, `AckMessage` mocked):
   
   - `TestSimpleConsumerAckReturnsStatusError` and 
`TestPushConsumerAckReturnsStatusError`: status `OK` returns `nil`; 
`INVALID_RECEIPT_HANDLE` and `INTERNAL_ERROR` return `*ErrRpcStatus` with the 
code and message of the status. On `master` the non-OK cases fail with `got 
<nil>`.
   
   ```
   $ go test -race ./...   # ok
   $ go vet ./...          # clean
   ```
   
   **End-to-end** with a `SimpleConsumer` on a RocketMQ 5.x server: receive a 
message, ack it with the receipt handle changed to `"invalid-handle"`, then ack 
it normally.
   
   | | ack(invalid handle) | ack(valid handle) |
   |---|---|---|
   | `master` | `nil` | `nil` |
   | this PR | `ErrRpcStatus{INTERNAL_SERVER_ERROR(50001)}` | `nil` |
   | Java 5.2.2 | `InternalErrorException`, code 50001 | OK |
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to