Skip to content

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

Description

@redlsz

Before Creating the Enhancement Request

  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions