Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ public ProxyTopicRouteData getTopicRouteForProxy(ProxyContext ctx, List<Address>
String topicName) throws Exception {
MessageQueueView messageQueueView = getAllMessageQueueView(ctx, topicName);
TopicRouteData topicRouteData = messageQueueView.getTopicRouteData();
return new ProxyTopicRouteData(topicRouteData, grpcPort);

if (requestHostAndPortList != null && !requestHostAndPortList.isEmpty()) {
return new ProxyTopicRouteData(topicRouteData, requestHostAndPortList);
} else {
return new ProxyTopicRouteData(topicRouteData, grpcPort);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.common.net.HostAndPort;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.rocketmq.broker.BrokerController;
Expand Down Expand Up @@ -102,4 +103,22 @@ public void testGetTopicRouteForProxy() throws Throwable {
ConfigurationManager.getProxyConfig().getGrpcServerPort()))),
proxyTopicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(MixAll.MASTER_ID));
}

@Test
public void testGetTopicRouteForProxyWithRemotingClient() throws Throwable {
ProxyContext ctx = ProxyContext.create();

List<Address> remotingAddressList = Lists.newArrayList(
new Address(Address.AddressScheme.IPv4, HostAndPort.fromParts(
HostAndPort.fromString(BROKER_ADDR).getHost(),
ConfigurationManager.getProxyConfig().getRemotingListenPort()))
);

ProxyTopicRouteData proxyTopicRouteData = this.topicRouteService.getTopicRouteForProxy(ctx, remotingAddressList, TOPIC);

assertEquals(1, proxyTopicRouteData.getBrokerDatas().size());
assertEquals(
remotingAddressList,
proxyTopicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(MixAll.MASTER_ID));
}
}