xdkxlk commented on code in PR #5788:
URL: https://github.com/apache/rocketmq/pull/5788#discussion_r1059287625


##########
proxy/src/main/java/org/apache/rocketmq/proxy/grpc/v2/consumer/ReceiveMessageActivity.java:
##########
@@ -68,12 +68,23 @@ public void receiveMessage(ProxyContext ctx, 
ReceiveMessageRequest request,
             ProxyConfig config = ConfigurationManager.getProxyConfig();
 
             Long timeRemaining = ctx.getRemainingMs();
-            long pollTime = timeRemaining - 
Durations.toMillis(settings.getRequestTimeout()) / 2;
-            if (pollTime < 0) {
-                pollTime = 0;
+            long pollingTime;
+            if (request.hasLongPollingTimeout()) {
+                pollingTime = 
Durations.toMillis(request.getLongPollingTimeout());
+            } else {
+                pollingTime = timeRemaining - 
Durations.toMillis(settings.getRequestTimeout()) / 2;
+            }
+            if (pollingTime < 
config.getGrpcClientConsumerMinLongPollingTimeoutMillis()) {
+                pollingTime = 
config.getGrpcClientConsumerMinLongPollingTimeoutMillis();
+            }
+            if (pollingTime > 
config.getGrpcClientConsumerMaxLongPollingTimeoutMillis()) {
+                pollingTime = 
config.getGrpcClientConsumerMaxLongPollingTimeoutMillis();
             }
-            if (pollTime > 
config.getGrpcClientConsumerLongPollingTimeoutMillis()) {
-                pollTime = 
config.getGrpcClientConsumerLongPollingTimeoutMillis();
+
+            if (pollingTime > timeRemaining) {
+                writer.writeAndComplete(ctx, Code.ILLEGAL_POLLING_TIME, "The 
remaining time is not enough" +
+                    " for polling, please check await time or network");

Review Comment:
   Add timeRemaining in the error message is helpful for user to adjust 
parameters



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