apache / apache/rocketmq

[Enhancement] Make ReceiveMessageQueueSelector broker-sticky for reentrant orderly POP

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

Description

### Before Creating the Enhancement Request

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

### Summary

Reentrant orderly consumption (#6755) relies on a client retry (same attemptId) being routed back to **the same** broker, since OrderInfo and its attemptId match are broker-local state (QueueLevelConsumerManager.needBlock).

However, in ```ReceiveMessageActivity.ReceiveMessageQueueSelector#select```, when the requested broker is not availabe(eg: in a rolling update), it silently falls back to round-robins to an other one.

```
protected static class ReceiveMessageQueueSelector implements QueueSelector {

private final String brokerName;

public ReceiveMessageQueueSelector(String brokerName) {
this.brokerName = brokerName;
}

@Override
public AddressableMessageQueue select(ProxyContext ctx, MessageQueueView messageQueueView) {
try {
AddressableMessageQueue addressableMessageQueue = null;
MessageQueueSelector messageQueueSelector = messageQueueView.getReadSelector();

if (StringUtils.isNotBlank(brokerName)) {
addressableMessageQueue = messageQueueSelector.getQueueByBrokerName(brokerName);
}

if (addressableMessageQueue == null) {
addressableMessageQueue = messageQueueSelector.selectOne(true);
}
return addressableMessageQueue;
} catch (Throwable t) {
return null;
}
}
}
```

### Motivation

Avoid losing reentrancy and thus leaving the FIFO queue blocked until invisibleTime expires.

### Describe the Solution You'd Like

Make the selector broker-sticky, especially on a FIFO request carrying an attemptId.

### Describe Alternatives You've Considered

-

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at ReceiveMessageActivity.ReceiveMessageQueueSelector#select and trace how FIFO requests carrying an attemptId reach QueueLevelConsumerManager.needBlock. Check the existing reentrant orderly-consumption flow and broker availability handling; done means the relevant retry remains broker-sticky instead of silently selecting another broker when the requested broker is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.