dubbo3-solon-plugin
此插件,由社区成员(浅念)贡献
<dependency>
<groupId>org.noear</groupId>
<artifactId>dubbo3-solon-plugin</artifactId>
</dependency>
1、描述
分布式扩展插件。基于 dubbo3 适配的 rpc 插件。此插件需要使用 duboo3 配套的注册与发现插件。
2、配置示例
- pom.xml 增加专属的注册与发现服务包:
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-nacos</artifactId>
<version>${dubbo3.version}</version>
</dependency>
<!-- 或者 zk(nacos 与 zookeeper 二选一,或者别的注册服务包) -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-zookeeper</artifactId>
<version>${dubbo3.version}</version>
</dependency>
- app.yml 增加 dubbo3 配置:
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);
}
- 提供者(实现接口服务)
@DubboService(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 = Solon.context().getBean(DubboConsumeApp.class);
System.out.println(tmp.home());
}
@DubboReference(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/demo7014-rpc_dubbo3_sml