Convert Figma logo to code with AI

apache logoservicecomb-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

1,900
807
1,900
141

Top Related Projects

Integration with Netflix OSS components

40,439

The java implementation of Apache Dubbo. An RPC and microservice framework.

11,358

The Java gRPC implementation. HTTP/2 based RPC

12,398

AWS Service registry for resilient mid-tier load balancing and failover.

10,351

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

  1. Defining a REST endpoint:
@RestSchema(schemaId = "hello")
@Path("/")
public class HelloEndpoint {
    @GET
    @Path("/hello")
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "Hello, ServiceComb!";
    }
}
  1. 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
  1. Invoking a service:
RestTemplate restTemplate = RestTemplateBuilder.create();
ResponseEntity<String> responseEntity = restTemplate.getForEntity(
    "cse://serviceName/hello", String.class);
String result = responseEntity.getBody();

Getting Started

  1. 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>
  1. Create a main class with @EnableServiceComb annotation:
@SpringBootApplication
@EnableServiceComb
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
  1. Define your service endpoints and configure the service as shown in the code examples above.

  2. 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.

40,439

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.

11,358

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.

12,398

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.

10,351

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Java Chassis 中文 Maven Central License

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 TrainLatest VersionCompiled JDK VersionTested JDK VersionOpen APINotes
Java Chassis 33.2.1OpenJDK 17OpenJDK 173.0.xDepends on Spring Boot 3
Java Chassis 22.8.19OpenJDK 8OpenJDK 8, 11, 172.0.xDepends on Spring 5
Java Chassis 11.3.11OpenJDK 8OpenJDK 82.0.xEnd 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

mailing list: subscribe dev

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.

Star History Chart

License

Licensed under an Apache 2.0 license.