apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.49k stars 26.43k forks source link

Single interface registered incase of Multiple interface implementation to service #9458

Open saichandu415 opened 2 years ago

saichandu415 commented 2 years ago

I used 2.7.12 & 2.7.14 & 3.0.4 versions of Dubbo for maven multi module project, the problem is while the serviceImpl(UserService) is implementing 3 interfaces, only the one in the first gets registered with the service discovery (Nacos)

If I change the FetchUser interface next to implements keyword (UserService implements FetchUser) then fetchuser gets registered.

Am I missing something here? Or is it something a limitation to apache dubbo? Any help is appreciated. Thanks

My Service class implements multiple interfaces like below

package com.business.usermanagement.usecaseImpl

@Component @DubboService
public class UserService implements UserOnboarding, FetchUser, ModifyUser {

}

Base Application class as below

@SpringBootApplication
@DubboComponentScan("com.business.usermanagement")
public class UserManagementApplication {

    @DisableLog
    public static void main(String[] args) {
        SpringApplication.run(UserManagementApplication.class, args);
    }

}

and below is the dubbo configuration

dubbo:
  protocol:
    name: dubbo
    port: -1
  registry:
    address: nacos://${nacos.discovery.server-addr}/?username=${nacos.discovery.username}&password=${nacos.discovery.username}
  metadata-report:
    address: nacos://${nacos.discovery.server-addr}
  application:
    name: ${spring.application.name}
AlbumenJ commented 2 years ago

You can Dubbo ServiceConfig API or <dubbo:service> definition to define multiple service. Dubbo only support a service with one interface. You should register each interface to Dubbo even those target implementation are the same.

saichandu415 commented 2 years ago

Thanks @AlbumenJ Is it possible for you to provide some reference for the same? I am unaware of this approach.

AlbumenJ commented 2 years ago

ServiceConfig serviceConfig1 = new ServiceConfig<>(); serviceConfig1.setInterface(UserOnboarding.class); serviceConfig1.setTarget(xxx); serviceConfig1.export();

ServiceConfig serviceConfig2 = new ServiceConfig<>(); serviceConfig2.setInterface(FetchUser.class); serviceConfig2.setTarget(xxx); serviceConfig2export();

ServiceConfig< ModifyUser > serviceConfig3 = new ServiceConfig<>(); serviceConfig3setInterface(ModifyUser.class); serviceConfig3.setTarget(xxx); serviceConfig3.export();