Solon

dubbo3-solon-plugin

<dependency>
    <groupId>org.noear</groupId>
    <artifactId>dubbo3-solon-plugin</artifactId>
</dependency>

1、描述

分布式扩展插件。基于 dubbo3 适配的 rpc 插件。

2、配置示例

server.port: 8011

dubbo:
  application:
    name: hello
    owner: noear
  registry:
    address: nacos://localhost:8848
#    port default = ${server.port + 20000}

3、代码应用

  • 申明接口
public interface HelloService {
    String sayHello(String name);
}
  • 提供者(实现接口服务)
@Service(group = "hello")
@EnableDubbo
public class DubboProviderApp implements HelloService{
    public static void main(String[] args) {
        Solon.start(DubboProviderApp.class, args);
    }
    
    @Override
    public String sayHello(String name) {
        return "hello, " + name;
    }
}

  • 消息者
@EnableDubbo
@Controller
public class DubboConsumeApp {
    public static void main(String[] args) {
        Solon.start(DubboConsumeApp.class, args, app -> app.enableHttp(false));

        //通过手动模式直接拉取bean
        DubboConsumeApp tmp = Aop.get(DubboConsumeApp.class);
        System.out.println(tmp.home());
    }

    @Reference(group = "hello")
    HelloService helloService;

    @Mapping("/")
    public String home() {
        return helloService.sayHello("noear");
    }
}

4、代码演示

https://gitee.com/noear/solon-examples/tree/main/7.Solon-Remoting-Rpc/demo7011-rpc_dubbo_sml