tree: 6921bdf43b481496b579bed41d66bbfe72b073f7 [path history] [tgz]
  1. src/
  2. pom.xml

ServiceComb-Service-Center Client for Java

Sample Java client for ServiceComb-Service-Center HTTP API.
If you want more information about the ServiceComb-Service-Center HTTP API, go here.

Build & Install

local Build from source :

 maven clean install

add dependency to maven


Basic Usage

Case 1: Health check

ServiceCenterClient client = new ServiceCenterClient();

//get service-center instance
MicroserviceInstancesResponse instances = client.getServiceCenterInstances();

Case 2: Register microservice

ServiceCenterClient client = new ServiceCenterClient();

// state Microservice object, and you have to set a serviceName
Microservice microservice = new Microservice();

//register microservice
String response = client.registerMicroservice(microservice);

Case 3: Get microservice list

ServiceCenterClient client = new ServiceCenterClient();

//get services lists
MicroservicesResponse services = client.getMicroserviceList();

Case 4: Register service instance

ServiceCenterClient client = new ServiceCenterClient();

//state MicroserviceInstance object, you have to set existed serviceId
MicroserviceInstance instance = new MicroserviceInstance();

//register service instanceId, return instanceId
String instanceId = client.registerMicroserviceInstance(instance, "222222");

Case 5: Get service instances list

ServiceCenterClient client = new ServiceCenterClient();

// get instances list with servcieId being "222222"
MicroserviceInstancesResponse instances = client.getMicroserviceInstanceList("222222");

Case 6: Heartbeats

ServiceCenterClient client = new ServiceCenterClient();

//all services and all instances send heartbeats
MicroservicesResponse services = client.getMicroserviceList();
for(Microservice microservice : services.getServices())
  for (MicroserviceInstance instance: client.getMicroserviceInstanceList(microservice.getServiceId()).getInstances())
    client.sendHeartBeats(new HeartbeatsRequest(microservice.getServiceId(),instance.getInstanceId())); 

Other API

You can see client API code and tests, go here

More development

  • Support All Service-center HTTP API


Bugs/Feature : issues