CRecordForwardToMicroServiceInstance
Send a message to the microservice registry, which forwards it to a desired microservice.
This message belongs to the microservice registry API.
{
"id": "4dad52bd-3071-46d9-a79b-c5188e311131",
"name": "FORWARD_TO_MICRO_SERVICE_INSTANCE",
"isService": "false",
"description": "Forward a message to an instance of a given microservice ID.\nIf more than one instance is registered, forward the message to a random instance.",
"slots": [
{
"key": "1",
"name": "MESSAGE",
"direction": "REQUEST",
"mandatory": "true",
"type": "MESSAGE",
"description": "The message to forward."
},
{
"key": "2",
"name": "MICRO_SERVICE_ID",
"direction": "REQUEST",
"mandatory": "true",
"type": "ID",
"description": "The microservice to search for."
}
]
}
Message Arguments
| Key | Name | Direction | Mandatory | Type | Description |
|---|---|---|---|---|---|
| 1 | MESSAGE | REQUEST | true | MESSAGE | The message to forward. |
| 2 | MICRO_SERVICE_ID | REQUEST | true | ID | The microservice to search for. |
Usage
Example of use (after generating of the class CRecordForwardToMicroServiceInstance):
private void sendViaMicroserviceRegistry(@NotNull final CTargetAddress aAddressOfMicroserviceRegistry, @NotNull final IId aMicroserviceId, @NotNull final CMessage aMessage) throws CException { final CEnvelope env = CEnvelope.forSingleTarget(aAddressOfMicroserviceRegistry); final CRecord rec = CRecordForwardToMicroServiceInstance.create(); CRecordForwardToMicroServiceInstance.setMicroServiceId(rec, aMicroserviceId); CRecordForwardToMicroServiceInstance.setMessage(rec, aMessage); sendRequest(env, rec); }
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.