You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "redoom (via GitHub)" <gi...@apache.org> on 2025/11/15 04:09:01 UTC

[PR] Add dubbo-samples-async-result [dubbo-samples]

redoom opened a new pull request, #1272:
URL: https://github.com/apache/dubbo-samples/pull/1272

   ## Summary
   
     Add a sample project demonstrating **AsyncRpcResult**
   
   ## Features
   
   ### Four AsyncRpcResult Patterns in Provider Filters
   
     1. **AsyncShortCircuitFilter**
        - Create `AsyncRpcResult` without invoking service
        - Use case: Cache, circuit breaker, rate limiting
   
     2. **DecorateResultFilter** 
        - Decorate results using `getResponseFuture().thenApply()`
        - Use case: Response wrapping, logging
   
     3. **AttachAndDecorateFilter** 
        - Add attachments for distributed tracing
        - Use case: trace-id, span-id propagation
   
     4. **EventDrivenFilter**
        - Integrate external async services
        - Use case: Async HTTP, MQ, reactive DB
   
   ### Two Consumer Async Patterns
   
     - **Method 1**: `CompletableFuture<T>` in method signature
     - **Method 2**: `@DubboReference(async=true)` + `RpcContext.getCompletableFuture()
   
   ## Module Structure
   
     - **interface**: Service definitions
     - **provider**: Implementation + 4 async Filters
     - **consumer**: Demonstrates both async invocation methods
     
   [https://github.com/apache/dubbo/issues/15567](url)


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Add dubbo-samples-async-result [dubbo-samples]

Posted by "zrlw (via GitHub)" <gi...@apache.org>.
zrlw commented on code in PR #1272:
URL: https://github.com/apache/dubbo-samples/pull/1272#discussion_r2671666835


##########
2-advanced/dubbo-samples-async-result/dubbo-samples-async-result-consumer/src/test/java/org/apache/dubbo/async/result/consumer/ConsumerTest.java:
##########
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.async.result.consumer;
+
+import org.apache.dubbo.ConsumerApplication;
+import org.apache.dubbo.HiConsumer;
+import org.apache.dubbo.HiService;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.dubbo.rpc.RpcContext;
+
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+@SpringBootTest(classes = ConsumerApplication.class)
+public class ConsumerTest {
+    private static final Logger log = LoggerFactory.getLogger(ConsumerTest.class);
+
+    @Autowired
+    private HiConsumer consumer;
+
+    @DubboReference(async = true, check = false)
+    private HiService hiService;
+
+    @DubboReference(check = false)
+    private HiService hiServiceSync;
+
+    @Test
+    public void testAsyncCallMethod1WithFilterChain() throws Exception {
+        CompletableFuture<String> future = hiService.sayHelloAsync("Alice");
+        if (future == null) {
+            throw new RuntimeException("Future should not be null");

Review Comment:
   should use assertion statements instead of throwing exception or logging info.



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Add dubbo-samples-async-result [dubbo-samples]

Posted by "redoom (via GitHub)" <gi...@apache.org>.
redoom commented on PR #1272:
URL: https://github.com/apache/dubbo-samples/pull/1272#issuecomment-3538789245

   I see the failing module is 3-extensions/protocol/dubbo-samples-triple, but my current changes should not have involved this module.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org