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."
    }
  ]
}

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;
}

nyssr.net - Innovative Distributed System