Dubbo和Java chassis底层都使用了Spring的依赖注入和bean管理系统,所以使用Dubbo的服务迁移到ServiceComb工作量较小, 主要改动在依赖和配置方面。
服务提供方
替换依赖
将对dubbo的依赖替换为对Java chassis的依赖
Dubbo
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
Java chassis
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>java-chassis-dependencies</artifactId>
<version>${java.chassis.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>transport-highway</artifactId>
</dependency>
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>transport-rest-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>provider-pojo</artifactId>
</dependency>
</dependencies>
替换服务接口注释
以 @Service 注释方式暴露的服务接口,用 @RpcSchema 替代
Dubbo
import com.alibaba.dubbo.config.annotation.Service;
@Service
public class SomeServiceImpl implements SomeService {
// ...
}
Java chassis
@RpcSchema(schemaId = "someServiceEndpoint")
public class SomeServiceImpl implements SomeService {
// ...
}
修改提供方启动入口
Dubbo
public class ProviderMain
{
public static

这篇博客详细介绍了如何将使用Dubbo的服务平滑迁移到ServiceComb,主要涉及服务提供方和服务消费方的改造,包括替换依赖、修改接口注释、启动入口调整以及配置文件的变更。迁移过程因两者都基于Spring,故工作量相对较小。
最低0.47元/天 解锁文章
2919

被折叠的 条评论
为什么被折叠?



