CRecordGetMicroServices
This message is used to fetch the registered microservices.
This message belongs to the microservice registry API.
{
"id": "5f7e230e-cc3e-4860-b2d1-f1dba272e85b",
"name": "GET_MICRO_SERVICES",
"isService": "false",
"description": "Get the registered microservices.",
"slots": [
{
"key": "90003",
"name": "MICRO_SERVICES",
"direction": "REQUEST",
"mandatory": "false",
"type": "RECORD_ARRAY",
"description": "The registered microservices."
}
]
}
Message Arguments
| Key | Name | Direction | Mandatory | Type | Description |
|---|---|---|---|---|---|
| 90003 | MICRO_SERVICES | REQUEST | false | RECORD_ARRAY |
An array containing descriptions of the registered microservices. Records are from type CRecordMicroService. |
Usage
Example of use (after generating of the class CRecordGetMicroServices):
// in constructor:
addMessageHandler(CRecordGetMicroServices.ID,
this::asyncGetMicroServices);
// request
private void sendGetMicroServices(@NotNull final CTargetAddress aAddressOfMicroserviceRegistry) throws CException
{
final CEnvelope env = CEnvelope.forSingleTarget(aAddressOfMicroserviceRegistry);
final CRecord rec = CRecordGetMicroServices.create();
sendRequest(env,
rec);
}
// fetch microservice data from reply
private boolean asyncGetMicroServices(@NotNull final CEnvelope aEnvelope,
@NotNull final CRecord aRecord) throws CException
{
if (aEnvelope.isAnswer())
{
final CRecord[] records = CRecordGetMicroServices.getMicroServices(aRecord,
null);
if (records != null)
{
for (CRecord record : records)
{
final IId id = CRecordMicroService.getId(record,
null);
final String description = CRecordMicroService.getDescription(record,
"");
final CRecord[] apiRecords = CRecordMicroService.getApi(record,
null);
if (apiRecords != null)
{
for (CRecord apiRecord : apiRecords)
{
final IId recordId = CRecordDescriptionOfRecord.getId(apiRecord,
null);
final String recordDescription = CRecordDescriptionOfRecord.getDescription(apiRecord,
"");
// ...
}
}
// ...
}
// ...
}
return true;
}
return false;
}
Record Usage
In
One or more descriptions of these Records are stored in the JSON or XML format
as record.json or record.xml within a directory.
The Record Generator, an included Swing tool, generates helper classes from these files.
These classes can then be used to type-safely write or read messages.