alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.93k stars 8.33k forks source link

How to use Dubbo-client invoking SpringCloud-Alibaba Dubbo Service? #2128

Closed tyhqiushen closed 3 years ago

tyhqiushen commented 3 years ago

My provider uses SpringCloud-Alibaba integration with Dubbo to provide services, and the registry uses Nacos

But Consumer hesitated to use Dubbo alone instead of Springcloud-Alibaba for a variety of reasons.

Currently, the service name shown on Nacos is xxxService, but the service name used by the Consumer invocation is xxxService DEFAULT_GROUP @ @ will: com. Ft. Iot. Xxxservice. RPC. Xxxservice: 1.0.0: testgroupname

The service registered on NACOS could not be found.

How can I handle this situation so that I can call the service provided by SpringCloud-Alibaba Dubbo while using only Dubbo?

我的provider使用SpringCloud-Alibaba集成Dubbo提供Service,注册中心使用了Nacos

但是Consumer犹豫种种原因,不能使用SpringCloud-Alibaba,只能单独使用Dubbo。

目前,在Nacos上显示的服务名为xxxService,但是Consumer调用使用的服务名为 DEFAULT_GROUP@@providers:com.ft.iot.xxxservice.rpc.XxxService:1.0.0:testgroupname

无法找到Nacos上注册的服务。

请问,这种情况我如何处理,才能在仅使用Dubbo的情况下去调用SpringCloud-Alibaba Dubbo提供的服务?

theonefx commented 3 years ago

In your provider side and consumer side, how to configure the registry address respectively, can you post it? 在你的provider端和consumer端,分别是如何配置注册中心地址的,能否贴一下?

tyhqiushen commented 3 years ago

provider端配置如下:

spring:
  application:
    name: messagedata-server
  main:
    allow-bean-definition-overriding: true
  cloud:
    nacos:
      config:
        server-addr: 192.168.25.43:32880
        username: nacos
        password: nacos
        namespace: tangyunhan
        file-extension: properties
        group: IOT
        refresh-enabled: false
        extension-configs:
          - data-id: iot_messagedataserver_redis_config
            group: IOT
          - data-id: iot_messagedataserver_mysql_config
            group: IOT
          - data-id: iot_messagedataserver_dubbo_config
            group: IOT
      discovery:
        server-addr: 192.168.25.43:32880
        username: nacos
        password: nacos
        namespace: tangyunhan

consumer端配置如下:

<dubbo:application name="consumer-app" />

<dubbo:registry address="nacos://192.168.25.43:32880?namespace=tangyunhan&username=nacos&password=nacos" username="nacos" password="nacos" />

<dubbo:reference
        id="messageDataService"
        interface="com.ft.iot.messagedata.rpc.MessageDataService"
        version="1.0.0"
        group="iot_messagedata"
        protocol="dubbo" services="messagedata-server">
</dubbo:reference>
theonefx commented 3 years ago

In the provider side configuration you posted, i can't find the dubbo configuration.

tyhqiushen commented 3 years ago

In the provider side configuration you posted, i can't find the dubbo configuration.

provider application.yml:

spring:
  application:
    name: messagedata-server
  main:
    allow-bean-definition-overriding: true
  cloud:
    nacos:
      config:
        server-addr: 192.168.25.43:32880
        username: nacos
        password: nacos
        namespace: tangyunhan
        file-extension: properties
        group: IOT
        refresh-enabled: false
        extension-configs:
          - data-id: iot_messagedataserver_redis_config
            group: IOT
          - data-id: iot_messagedataserver_mysql_config
            group: IOT
          - data-id: iot_messagedataserver_dubbo_config
            group: IOT
      discovery:
        server-addr: 192.168.25.43:32880
        username: nacos
        password: nacos
        namespace: tangyunhan

nacos configuration data-id 'iot_messagedataserver_dubbo_config':

server.port=9530
dubbo.scan.base-packages=com.ft.iot.controller.rpc
dubbo.config.multiple=true
dubbo.protocols.dubbo.id=myxieyi1
dubbo.protocols.dubbo.name=dubbo
dubbo.protocols.dubbo.port=20885
dubbo.protocols.dubbo.serialization=hessian2
dubbo.protocols.dubbo.charset=UTF-8
dubbo.protocols.rmi.id=myxieyi2
dubbo.protocols.rmi.name=rmi
dubbo.protocols.rmi.port=8082
dubbo.protocols.rmi.serialization=hessian2
dubbo.protocols.rmi.charset=UTF-8

In program service:

@DubboService(
    interfaceClass = MessageDataService.class,
    version = "1.0.0",
    interfaceName = "messageDataService",
    group = "iot_messagedata",
    actives = 2,
    connections = 10,
    cluster = "failfast",
    timeout = 30000,
    methods = {
        @Method(name = "findMessageByPushsn", executes = 20, timeout = 3000),
        @Method(name = "findMessageByCustomersn", executes = 20)
    }
)
public class MessageDataRpcController implements MessageDataService {
    ...
}
theonefx commented 3 years ago

Sorry, this integration mode of yours is not supported temporarily. Dubbo be inherited by SCA with an DubboCloudRegistry whose data format can only be recognized by the SCA framework.

if you want to make it works, you can use the original dubbo registry, which is to configure the Nacos registry directly for Dubbo.