开发服务提供者(RPC)

提供RPC服务提供者接口,将接口暴露出去,供其他服务调用
以rbac为例,提供给其他服务

开发步骤

1.在jecloud-rbac-facade模块中编写RPC服务提供者接口



public interface DepartmentRpcService {

    /**
     * 查找部门领导
     * @param departmentId
     * @return
     */
    String findDeptLeader(String departmentId);

}

2. 在jecloud-rbac-impl中实现RPC服务提供者接口


@RpcSchema(schemaId = "departmentRpcService")
public class DepartmentRpcServiceImpl implements DepartmentRpcService {

    @Autowired
    private RbacDepartmentService rbacDepartmentService;

    @Override
    public String findDeptLeader(String departmentId) {
        return rbacDepartmentService.findDeptLeader(departmentId);
    }

}

3. 在jecloud-rbac-sdk中实现RPC服务提供者接口远程调用


@Service
public class DepartmentRpcServiceImpl implements DepartmentRpcService {

    @RpcReference(microserviceName = "rbac",schemaId = "departmentRpcService")
    private DepartmentRpcService departmentRpcService;

    @Override
    public String findDeptLeader(String departmentId) {
        return departmentRpcService.findDeptLeader(departmentId);
    }

}

最后编辑: 于春辉  文档更新时间: 2024-11-08 17:00   作者:刘利军