servicecomb-java-chassis
ServiceComb Java Chassis is a Software Development Kit (SDK) for rapid development of microservices in Java, providing service registration, service discovery, dynamic routing, and service management features
Top Related Projects
Integration with Netflix OSS components
The java implementation of Apache Dubbo. An RPC and microservice framework.
The Java gRPC implementation. HTTP/2 based RPC
AWS Service registry for resilient mid-tier load balancing and failover.
Apache Thrift
Quick Overview
Apache ServiceComb Java Chassis is a microservice development framework for Java that aims to provide a simple and efficient way to develop microservices. It offers features like service registration, discovery, load balancing, and fault tolerance, while also supporting multiple communication protocols.
Pros
- Supports multiple protocols (REST, Highway, gRPC) for service communication
- Provides built-in service governance features like circuit breakers and rate limiting
- Offers easy integration with popular cloud platforms and container orchestration tools
- Includes a lightweight and fast invocation chain for improved performance
Cons
- Learning curve may be steep for developers new to microservices architecture
- Documentation could be more comprehensive and up-to-date
- Limited community support compared to some other microservices frameworks
- May have compatibility issues with certain Java versions or libraries
Code Examples
- Defining a REST endpoint:
@RestSchema(schemaId = "hello")
@Path("/")
public class HelloEndpoint {
@GET
@Path("/hello")
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello, ServiceComb!";
}
}
- Configuring a service:
APPLICATION_ID: myapp
service_description:
name: myservice
version: 0.0.1
servicecomb:
service:
registry:
address: http://127.0.0.1:30100
rest:
address: 0.0.0.0:8080
- Invoking a service:
RestTemplate restTemplate = RestTemplateBuilder.create();
ResponseEntity<String> responseEntity = restTemplate.getForEntity(
"cse://serviceName/hello", String.class);
String result = responseEntity.getBody();
Getting Started
- Add the ServiceComb dependency to your
pom.xml
:
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>java-chassis-spring-boot-starter-standalone</artifactId>
<version>2.8.0</version>
</dependency>
- Create a main class with
@EnableServiceComb
annotation:
@SpringBootApplication
@EnableServiceComb
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
-
Define your service endpoints and configure the service as shown in the code examples above.
-
Run your application and access the services using the provided REST endpoints or through service invocation.
Competitor Comparisons
Integration with Netflix OSS components
Pros of Spring Cloud Netflix
- Extensive ecosystem and integration with Spring Boot
- Robust service discovery and load balancing with Eureka
- Circuit breaker pattern implementation with Hystrix
Cons of Spring Cloud Netflix
- Heavier footprint and potential performance overhead
- Steeper learning curve for developers new to Spring ecosystem
- Some components (e.g., Hystrix) are in maintenance mode
Code Comparison
Spring Cloud Netflix:
@EnableEurekaClient
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
ServiceComb Java Chassis:
@RpcSchema(schemaId = "hello")
public class HelloImpl implements Hello {
public String sayHello(String name) {
return "Hello " + name;
}
}
Spring Cloud Netflix focuses on annotations and configuration for service registration and discovery, while ServiceComb Java Chassis emphasizes a more lightweight approach with RPC schemas. Spring Cloud Netflix provides a comprehensive set of tools for building microservices, but may introduce complexity and overhead. ServiceComb Java Chassis offers a simpler, performance-oriented alternative, but with a smaller ecosystem and community support compared to Spring Cloud Netflix.
The java implementation of Apache Dubbo. An RPC and microservice framework.
Pros of Dubbo
- Larger community and ecosystem, with more extensive adoption in production environments
- More comprehensive documentation and tutorials available
- Supports multiple protocols (e.g., Dubbo, gRPC, REST) out of the box
Cons of Dubbo
- Steeper learning curve due to its extensive feature set
- Heavier runtime footprint compared to ServiceComb-Java-Chassis
- Configuration can be more complex for simple use cases
Code Comparison
ServiceComb-Java-Chassis:
@RestSchema(schemaId = "hello")
@Path("/")
public class HelloEndpoint {
@GET
@Path("/hello")
public String hello() {
return "Hello, ServiceComb!";
}
}
Dubbo:
public interface HelloService {
String sayHello(String name);
}
@Service
public class HelloServiceImpl implements HelloService {
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
Both frameworks offer annotations for defining services, but ServiceComb-Java-Chassis uses JAX-RS style annotations, while Dubbo uses its own annotations and interface-based approach. ServiceComb-Java-Chassis tends to have a more RESTful focus, while Dubbo is more RPC-oriented by default, though both support multiple protocols.
The Java gRPC implementation. HTTP/2 based RPC
Pros of grpc-java
- Highly optimized for performance with efficient binary serialization
- Extensive language support beyond Java, enabling cross-language communication
- Strong focus on streaming capabilities, ideal for real-time applications
Cons of grpc-java
- Steeper learning curve due to protocol buffer definitions and code generation
- Less flexibility in terms of message formats, primarily using Protocol Buffers
- More complex setup and configuration compared to RESTful services
Code Comparison
servicecomb-java-chassis:
@RestSchema(schemaId = "hello")
@Path("/")
public class HelloEndpoint {
@GetMapping(path = "/hello")
public String hello() {
return "Hello, ServiceComb!";
}
}
grpc-java:
public class HelloServiceImpl extends HelloServiceGrpc.HelloServiceImplBase {
@Override
public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
HelloResponse response = HelloResponse.newBuilder().setMessage("Hello, gRPC!").build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}
The code comparison shows that servicecomb-java-chassis uses a more familiar REST-style approach, while grpc-java requires implementing generated service classes and working with Protocol Buffer messages.
AWS Service registry for resilient mid-tier load balancing and failover.
Pros of Eureka
- Widely adopted and battle-tested in large-scale production environments
- Seamless integration with other Netflix OSS components
- Simple setup and configuration for basic use cases
Cons of Eureka
- Limited built-in support for advanced service governance features
- Less flexible in terms of protocol support and extensibility
- Primarily designed for Java-based microservices
Code Comparison
ServiceComb-Java-Chassis:
@RpcSchema(schemaId = "hello")
public class HelloEndpoint {
@GetMapping(path = "/hello")
public String hello(@RequestParam(name = "name") String name) {
return "Hello " + name;
}
}
Eureka:
@SpringBootApplication
@EnableEurekaClient
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Key Differences
- ServiceComb-Java-Chassis offers a more comprehensive microservices framework with built-in service governance features
- Eureka focuses primarily on service discovery and registration
- ServiceComb-Java-Chassis supports multiple protocols (REST, Highway, gRPC) while Eureka is mainly HTTP-based
- ServiceComb-Java-Chassis provides more fine-grained control over service configurations and behaviors
Both projects aim to simplify microservices development, but ServiceComb-Java-Chassis offers a more holistic approach with additional features beyond service discovery.
Apache Thrift
Pros of Thrift
- Broader language support, enabling cross-language RPC
- More mature and widely adopted in industry
- Efficient binary serialization protocol
Cons of Thrift
- Less focus on microservices architecture
- Steeper learning curve for complex use cases
- Limited built-in service governance features
Code Comparison
Thrift IDL example:
service Calculator {
i32 add(1:i32 num1, 2:i32 num2)
}
ServiceComb-Java-Chassis interface definition:
@RestSchema(schemaId = "calculator")
@Path("/calculator")
public interface CalculatorService {
@Path("/add")
@GET
int add(@QueryParam("num1") int num1, @QueryParam("num2") int num2);
}
Key Differences
- Thrift uses a custom IDL, while ServiceComb-Java-Chassis leverages standard Java annotations
- Thrift focuses on RPC, whereas ServiceComb-Java-Chassis is designed for microservices
- ServiceComb-Java-Chassis provides more built-in features for service governance and discovery
- Thrift offers better performance for binary data serialization
- ServiceComb-Java-Chassis integrates more easily with Java ecosystem tools and frameworks
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Java Chassis ä¸æ
Apache ServiceComb Java Chassis is a Software Development Kit (SDK) for rapid development of microservices in Java, providing service registration, service discovery, dynamic routing, and service management features.
releases
Release Train | Latest Version | Compiled JDK Version | Tested JDK Version | Open API | Notes |
---|---|---|---|---|---|
Java Chassis 3 | 3.2.1 | OpenJDK 17 | OpenJDK 17 | 3.0.x | Depends on Spring Boot 3 |
Java Chassis 2 | 2.8.19 | OpenJDK 8 | OpenJDK 8, 11, 17 | 2.0.x | Depends on Spring 5 |
Java Chassis 1 | 1.3.11 | OpenJDK 8 | OpenJDK 8 | 2.0.x | End of Support |
NOTICE: Since Open API 3.0.x is not compatible with 2.0.x, Java Chassis 2 and Java Chassis 1 can not work together with Java Chassis 3. All related consumers, providers and edge service need use Java Chassis 3 when upgrading.
NOTICE: Java Chassis 1 reached its end of support now after it's first release from 2018.
Quick Start
- Define API
@RequestMapping(path = "/provider")
public interface ProviderService {
@GetMapping("/sayHello")
String sayHello(@RequestParam("name") String name);
}
- Provider service
@RestSchema(schemaId = "ProviderController", schemaInterface = ProviderService.class)
public class ProviderController implements ProviderService {
@Override
public String sayHello(String name) {
return "Hello " + name;
}
}
- Consumer service
@Configuration
public class ProviderServiceConfiguration {
@Bean
public ProviderService providerService() {
return Invoker.createProxy("provider", "ProviderController", ProviderService.class);
}
}
Invoke Provider service with RPC
@RestSchema(schemaId = "ConsumerController", schemaInterface = ConsumerService.class)
public class ConsumerController implements ConsumerService {
private ProviderService providerService;
@Autowired
public void setProviderService(ProviderService providerService) {
this.providerService = providerService;
}
@Override
public String sayHello(String name) {
return providerService.sayHello(name);
}
}
Try out this example here .
Documentation
Project documentation is available on the ServiceComb Java Chassis Developer Guide.
Building
You donât need to build from source to use Java Chassis (binaries in apache nexus ), but if you want to try out the latest and greatest, Java Chassis can be easily built with the maven. You also need JDK 17.
mvn clean install
The first build may take a longer than expected as Maven downloads all the dependencies.
Automated Testing
To build the docker image and run the integration tests with docker, you can use maven docker profile
mvn clean install -Pdocker -Pit
If you are using docker machine, please use the following command
mvn clean install -Pdocker -Pit -Pdocker-machine
Contact
Bugs: issues
Contributing
See CONTRIBUTING for details on submitting patches and the contribution workflow.
Star this project
If you like this project, do not forget star it.
License
Licensed under an Apache 2.0 license.
Top Related Projects
Integration with Netflix OSS components
The java implementation of Apache Dubbo. An RPC and microservice framework.
The Java gRPC implementation. HTTP/2 based RPC
AWS Service registry for resilient mid-tier load balancing and failover.
Apache Thrift
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot