Aias00 opened a new pull request, #10607:
URL: https://github.com/apache/rocketmq/pull/10607

   ## Which issue does this PR close?
   
   Closes #10559.
   
   ## What's the purpose of this PR
   
   Add NATS-style wildcard pattern matching so a wildcard LiteTopic consumer 
group can subscribe to a **subset** of lite-topics under its parent topic 
(instead of always receiving all of them), using `__` as the segment separator. 
Full backward compatibility is preserved: wildcard groups without patterns 
behave identically to before.
   
   ## Brief changelog
   
   - **`LitePatternMatcher` (new, `common`)** — the matching engine: 
`validate`, `matches` (recursive, no regex), `matchesAny`, `expand`. `*` 
matches exactly one `__`-delimited segment; `**` matches one or more trailing 
segments (like NATS `>`).
   - **`LiteSubscription`** — add in-memory `wildcardPatterns` set (rebuilt on 
reconnect, same as `liteTopicSet`).
   - **`LiteSubscriptionRegistry[Impl]`** — a wildcard group with non-empty 
validated patterns enters **pattern mode**: eagerly expand against 
`collectByParentTopic` and register real lmqNames. Empty patterns keep legacy 
receive-all behavior (synthetic `topic@group` key) unchanged. 
`getAllSubscriber` always merges the synthetic-key clients for any wildcard 
group, so mixed pattern/legacy groups deliver to both. New 
`reexpandWildcardPatterns` picks up lite-topics created after the initial 
subscription.
   - **`LiteSubscriptionCtlProcessor`** — route wildcard `COMPLETE_ADD` through 
`toWildcardPatterns` (patterns ride the existing `liteTopicSet` — **no wire 
protocol change**). Non-empty but all-invalid pattern input is **rejected** 
instead of silently widening to receive-all.
   - **`LiteEventDispatcher.doFullDispatchForWildcardGroup`** — replace the 
O(N) `forEachLiteTopic` scan with O(M) `collectByParentTopic`; re-expand 
patterns for new LMQs and clear backlog per pattern-mode client.
   
   ### Pattern semantics
   
   | Pattern | Matches | Does NOT match |
   |---|---|---|
   | `pay__refund` | `pay__refund` | `pay__refund__notify`, `notify__refund` |
   | `pay__*` | `pay__refund`, `pay__success` | `pay__refund__notify` |
   | `*__refund` | `pay__refund`, `notify__refund` | `pay__refund__notify` |
   | `pay__*__notify` | `pay__refund__notify`, `pay__success__notify` | 
`pay__refund` |
   | `**` | all | — |
   | `pay__**` | `pay__refund`, `pay__refund__notify` | `notify__refund` |
   
   ## How to test / verify
   
   - New `LitePatternMatcherTest` (common): all six issue rows (match + 
non-match), `validate` accept/reject cases, `expand`/`matchesAny` semantics — 
18 tests.
   - Updated registry/dispatcher/processor tests, split into legacy + 
pattern-mode variants; added mixed-group delivery, all-invalid-pattern 
rejection, and lazy re-expansion coverage.
   - `mvn -pl common,broker -am test` — lite suite green (138 tests, 0 
failures); checkstyle clean on common + broker.
   - Performance sanity: `matches` ≈ 1µs/call (target <5µs); `expand(1k 
candidates × 5 patterns)` ≈ 360µs (target <10ms).
   
   ## Scope
   
   Broker + common only, matching the issue's "Key Changes" table. Patterns are 
carried via the existing `LiteSubscriptionDTO.liteTopicSet`; the broker 
distinguishes them via `isWildcardGroup()`. A consumer/proxy API 
(`subscribeLite`) and a true LMQ-creation listener for sub-second new-topic 
pickup are intentionally deferred to follow-up PRs.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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