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

[GitHub] [dubbo] suncairong163 commented on a diff in pull request #12200: add spring cloud invoke dubbo rest & others program language invoke …

suncairong163 commented on code in PR #12200:
URL: https://github.com/apache/dubbo/pull/12200#discussion_r1179032029


##########
dubbo-demo/dubbo-demo-xml/dubbo-demo-jaxrs-rest-consumer/src/main/java/org/apache/dubbo/demo/rest/api/request/SpringCloudInvokeDubboRestConsumer.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.demo.rest.api.request;
+
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.dubbo.demo.rest.api.HttpService;
+import org.springframework.stereotype.Component;
+
+
+/**
+ *  if your service is spring cloud ,you want to request dubbo rest service
+ *
+ *  only if add the dependency of
+ *
+ *          <dependency>
+ *             <groupId>org.apache.dubbo</groupId>
+ *             <artifactId>dubbo-rpc-rest</artifactId>
+ *         </dependency>
+ *
+ *    and set the dubbo invoke url
+ */
+@Component
+public class SpringCloudInvokeDubboRestConsumer {
+
+    /**
+     *  URL rest://localhost:8888/services
+     *   rest protocol
+     *   localhost:8888 server address
+     *   services context path
+     */
+    @DubboReference(interfaceClass = HttpService.class ,url = "rest://localhost:8888/services",version = "1.0.0",group = "test")
+    HttpService httpService;
+
+    public void invokeHttpService() {
+        String http = httpService.http("Spring Cloud Invoke Dubbo Rest");
+        System.out.println(http);
+    }
+
+
+}

Review Comment:
   这个是为了演示 服务引入dubbo rest  和service api,进行dubbo service 调用的,需要改成feignclient那种调用吗?中间差个注册中心拉取微服务实例的转换,就直接用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