apache / apache/rocketmq

[Enhancement] Proxy v5 gRPC: implement QueryOffset / GetOffset so clients can read consumer offsets

Open
#10,434 3 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Java
Stars
22.6k
Forks
12k
Avg merge
2d 20h
Merged PRs (30d)
26

Description

### Before Creating the Enhancement Request

- [x] I have confirmed that this should be classified as an enhancement rather than a bug/feature.

### Summary

The problem is [`service.proto`](https://github.com/apache/rocketmq-clients/blob/master/cpp/proto/apache/rocketmq/v2/service.proto) declares `QueryOffset`, `GetOffset`, `UpdateOffset`, and `PullMessage` on `MessagingService`. The proxy's gRPC server ([`GrpcMessagingApplication.java`](https://github.com/apache/rocketmq/blob/develop/proxy/src/main/java/org/apache/rocketmq/proxy/grpc/v2/GrpcMessagingApplication.java)) has no `@Override` methods for them, so every call returns `UNIMPLEMENTED`. Verified live against RocketMQ 5.3.2.

### Motivation

Any tool built on the v5 client (autoscalers, exporters, lag dashboards) can't read offsets through the official gRPC API. They have to fall back to the legacy remoting protocol — which is exactly what v5 was supposed to replace. Concrete consumer: [kedacore/keda#6149](https://github.com/kedacore/keda/issues/6149) — RocketMQ autoscaling in KEDA.

### Describe the Solution You'd Like

The proxy **already has** the Java methods that would do the work — they're in [`MessagingProcessor`](https://github.com/apache/rocketmq/blob/develop/proxy/src/main/java/org/apache/rocketmq/proxy/processor/MessagingProcessor.java):

- `getMaxOffset(ctx, mq, timeoutMillis)` — already used internally
- `queryConsumerOffset(ctx, mq, group, timeoutMillis)` — already used internally

Both call the broker via the existing remoting opcodes (`GET_MAX_OFFSET=30`, `QUERY_CONSUMER_OFFSET=14`). So adding the gRPC overrides is pure wiring at one layer — no new business logic, no broker-side changes, no proto changes.

### Proposed change

- New `proxy/.../grpc/v2/consumer/OffsetActivity.java` (mirrors `RouteActivity`).
- Add `@Override queryOffset` + `@Override getOffset` to `GrpcMessagingApplication` (copy the `queryRoute` template at line 204).
- Wire through `GrpcMessagingActivity` + `DefaultGrpcMessagingActivity`.
- Unit tests against a mocked `MessagingProcessor`.

### Describe Alternatives You've Considered

-

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with service.proto and the queryRoute implementation in proxy/src/main/java/org/apache/rocketmq/proxy/grpc/v2/GrpcMessagingApplication.java. Trace GrpcMessagingActivity, DefaultGrpcMessagingActivity, and the proposed OffsetActivity wiring, then inspect MessagingProcessor's getMaxOffset and queryConsumerOffset methods. Done means QueryOffset and GetOffset no longer return UNIMPLEMENTED and unit tests pass with a mocked processor.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, java
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.