You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "zhaohai666 (via GitHub)" <gi...@apache.org> on 2026/09/23 02:51:40 UTC

[PR] Feat/nodejs message interceptor hooks [rocketmq-clients]

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

   ## P5 feat(nodejs): message interceptor hooks and NOTIFY_UNSUBSCRIBE_LITE_COMMAND
   
   New `src/hook/` package with all 8 hook points (`SEND`, `RECEIVE`, `CONSUME`, `ACK`,
   `CHANGE_INVISIBLE_DURATION`, `COMMIT_TRANSACTION`, `ROLLBACK_TRANSACTION`,
   `FORWARD_TO_DLQ`):
   
   - `MessageInterceptor` + `CompositedMessageInterceptor` (doBefore in order, doAfter in
     reverse, failures isolated), `Attribute` / `AttributeKey`,
     `MessageInterceptorContext(Impl)`, built-in `InflightRequestCountInterceptor`.
   - Wiring: SEND in `Producer#send`; RECEIVE / ACK / CHANGE_INVISIBLE_DURATION in
     `Consumer`; CONSUME in `ConsumeTask`; transaction hooks around `EndTransaction`;
     FORWARD_TO_DLQ around every DLQ RPC attempt.
   - `BaseClientOptions#messageInterceptor` accepts one interceptor or an array;
     registration is only allowed before the client runs.
   - `TelemetrySession` now dispatches `NOTIFY_UNSUBSCRIBE_LITE_COMMAND` (oneof field 9) to
     `BaseClient#onNotifyUnsubscribeLiteCommand`; `LitePushConsumerImpl` forwards it to
     `LiteSubscriptionManager`.
   
   **Tests:** `nodejs/test/hook.test.ts` (9 cases, offline, all pass)


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat/nodejs message interceptor hooks [rocketmq-clients]

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin merged PR #1384:
URL: https://github.com/apache/rocketmq-clients/pull/1384


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Feat/nodejs message interceptor hooks [rocketmq-clients]

Posted by "f1amingo (via GitHub)" <gi...@apache.org>.
f1amingo commented on PR #1384:
URL: https://github.com/apache/rocketmq-clients/pull/1384#issuecomment-5790124426

   Thanks for adding the Node.js message interceptor framework. I found three issues that should be addressed before merging:
   
   1. `Consumer.receiveMessage()` invokes `RECEIVE.doBefore` only after the RPC completes. This prevents `InflightRequestCountInterceptor` from tracking actual in-flight requests. On failure, it also creates a different context for `doAfter`. Please invoke `doBefore` before the RPC and reuse the same context for `doAfter`, consistent with the Java implementation.
   
   2. PushConsumer settlement bypasses the new hooks. `ProcessQueue` calls `ackMessageViaRpc()` and `changeInvisibleDurationViaRpc()` directly, but these methods do not trigger `ACK` or `CHANGE_INVISIBLE_DURATION`. Therefore, these hooks only work for SimpleConsumer. Please wrap the shared RPC methods so both consumer types have consistent behavior, including retries.
   
   3. `CompositedMessageInterceptor.doBefore()` creates a separate context for each interceptor, so later interceptors cannot see attributes added by earlier ones. Its `doAfter()` attribute merging may also overwrite an interceptor’s own attributes. Please preserve the accumulated context semantics used by the Java implementation.
   
   The current tests pass, but they do not cover these paths. Please add tests for RECEIVE timing/context reuse, PushConsumer ACK/change-invisible-duration hooks, and multi-interceptor attribute propagation.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org