Discover the Microservice Bus Microservice Bus provides a service registration/discovery and routing mechanism to simply the communications between services, The service consumers only need to talk with Microservice Bus without any address information of individual service providers. However, all the service consumers/providers must know the IP and service port of Microservice Bus. MSB suggests the following approach to discover the Microservice Bus.
Each service provider/consumer implementation can get the address of the Microservice Bus from a local config file via the key 'msb.address', the default value consists of a hostname and a service port. The hostname is 'msb.onap.org', which can be resolved by a DNS server in the local network, and the default port is 80. If a DNS server is not available in some deployments, an IP should be used instead.
...
Register service to the Microservice Bus
Operation | Register service to the Microservice Bus |
---|
URL | /api/microservices/v1/services |
---|
Verb | POST |
---|
Request |
Parameter | Mandatory | Parameter type | Data Type | Default | example | Description |
---|
Body | Y | Body | JSON String |
| {
"serviceName": "catalog",
"version": "v1",
"url": "/api/catalog/v1",
"protocol": "REST",
"visualRange": "1",
"nodes": [
{
"ip": "10.74.56.36",
"port": "8988",
"ttl": 0
}
]
}
| Described in the below table | createOrUpdate | N | Query | boolean | true |
| true: create new instances or replace the old instances if the instance with the same service name, ipand port exist
false: create new instances and remove all the old instances with the same service name |
Parameter | Mandatory | Data Type | Default | Description |
---|
serviceName | Y | String |
| Service Name | version | Y | String |
| Service Version | url | Y if protocol is 'REST' or 'UI' | String |
| the actual URL of the service to be registered | protocol | Y | String |
| supported protocols: 'REST', 'UI','TCP' | visualRange | F | String | 1 | Visibility of the service. External(can be accessed by external systems):0 Internal(can only be accessed by ONAP consumers):1 | nodes | Y | List |
| ip: the ipof the service instance node, it could also be a hostname like catalog.onap.org port: the port of the service instance node ttl: time to live, this parameter is reserved for later use |
|
---|
Response | example | Description |
---|
{
"serviceName": "catalog",
"version": "v1",
"url": "/api/catalog/v1",
"protocol": "REST",
"visualRange": "1",
"nodes": [
{
"ip": "10.74.55.66",
"port": "6666",
"ttl": 0,
"expiration": "2016-02-18T16:19:40+08:00",
"created_at": "2016-02-18T16:03:00+08:00",
"updated_at": "2016-02-18T16:03:00+08:00"
},
{
"ip": "10.74.56.37",
"port": "8989",
"ttl": 0,
"expiration": "2016-02-18T16:13:00+08:00",
"created_at": "2016-02-18T16:03:00+08:00",
"updated_at": "2016-02-18T16:03:00+08:00"
},
{
"ip": "10.74.56.36",
"port": "8988",
"ttl": 0,
"expiration": "2016-02-18T17:04:36+08:00",
"created_at": "2016-02-18T16:03:00+08:00",
"updated_at": "2016-02-18T16:03:00+08:00"
}
],
"status": "1"
}
| serviceName: service name version: version url: url of the created service instance protocol: supported protocols: 'REST', 'UI' nodes: the service instance nodes list to register ip: the ip of the service instance node, it could also be a hostname like catalog.onap.org port: the port of the service instance node ttl: time to live, this parameter is reserved for later use status: service status, 1: enabled,0:disabled |
|
---|
Success Code | 201 |
---|
Error Code | 415 Invalid Parameters 500 Internal Server Error |
---|
Unregister service from the Microservice Bus
Operation | Unregister service from the Microservice Bus |
---|
URL | /api/microservices/v1/services/{serviceName}/version/{version}/nodes/{ip}/{port} |
---|
Verb | DELETE |
---|
Request | Parameter | Mandatory | Parameter type | Data Type | Default | example | Description |
---|
serviceName | Y | Path | String |
|
| Service Name | version | N | Path | String |
|
| Service Version | ip | N | Path | String |
|
| the IP address of the service instance, it could also be a hostname like catalog.onap.org | port | N | Path | String |
|
| the port of the service instance |
|
---|
Response |
|
---|
Success Code | 204 |
---|
Error Code | 404 Can't find the service instance 415 Invalid Parameters 500 Internal Server Error |
---|
Query service from the Microservice Bus
...
if the service did not have version property, you can use the url without version.
/api/[servicename]/
Operation | Query service from the Microservice Bus |
---|
URL | /api/microservices/v1/services/{serviceName}/version/{version} |
---|
Verb | GET |
---|
Request | Parameter | Mandatory | Parameter type | Data Type | Default | example | Description |
---|
serviceName | N | Path | String |
|
| Service Name | version | N | Path | String |
|
| Service Version |
|
---|
Response | example | Description |
---|
{
"serviceName": "catalog",
"version": "v1",
"url": "/api/catalog/v1",
"protocol": "REST",
"visualRange": "1",
"nodes": [
{
"ip": "10.74.55.66",
"port": "6666",
"ttl": 0,
"expiration": "2016-02-18T16:19:40+08:00",
"created_at": "2016-02-18T16:03:00+08:00",
"updated_at": "2016-02-18T16:03:00+08:00"
},
{
"ip": "10.74.56.37",
"port": "8989",
"ttl": 0,
"expiration": "2016-02-18T16:13:00+08:00",
"created_at": "2016-02-18T16:03:00+08:00",
"updated_at": "2016-02-18T16:03:00+08:00"
},
{
"ip": "10.74.56.36",
"port": "8988",
"ttl": 0,
"expiration": "2016-02-18T17:04:36+08:00",
"created_at": "2016-02-18T16:03:00+08:00",
"updated_at": "2016-02-18T16:03:00+08:00"
}
],
"status": "1"
}
| serviceName: service name version: version url: url of the created service instance protocol: supported protocols: 'REST', 'UI', 'TCP' nodes: the service instance nodes list to register ip: the ip of the service instance node, it could also be a hostname like catalog.onap.org port: the port of the service instance node ttl: time to live, this parameter is reserved for later use status: service status, 1:eanbled,0:disabled |
|
---|
Success Code | 200 |
---|
Error Code | 404 Can't find the service instance 415 Invalid Parameters 500 Internal Server Error |
---|
To be continue