RPC
Commands and Queries request-reply RPC API in the KubeMQ Java SDK reference, covering sending and handling requests.
CQClient handles request–reply workloads. Commands embed timeouts in CommandMessage; queries extend Message with cache hints.
Commands
sendCommand
CommandResponseMessage sendCommand(CommandMessage message) throws KubeMQExceptionSends a command and blocks until a worker responds or the timeout elapses.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
message | CommandMessage | Yes | Channel, body/metadata, timeoutInSeconds, tags |
Returns: CommandResponseMessage — execution metadata and payload.
Note:
sendCommandRequestis a deprecated alias (deprecated since 2.2.0,forRemoval=trueat v3.0). PrefersendCommand.
subscribeToCommands
void subscribeToCommands(CommandsSubscription subscription) throws KubeMQExceptionRegisters a consumer that returns CommandResponseMessage from the handler callback.
CommandsSubscription fields:
| Field | Type | Description |
|---|---|---|
channel | String | Channel to listen on |
group | String | Consumer group |
onReceiveCommandCallback | Consumer<CommandMessageReceived> | Handler |
onErrorCallback | Consumer<KubeMQException> | Error hook |
Queries
sendQuery
QueryResponseMessage sendQuery(QueryMessage message) throws KubeMQExceptionQueryMessage extends CommandMessage with:
| Field | Type | Description |
|---|---|---|
cacheKey | String | Cache key for response reuse |
cacheTtlInSeconds | int | TTL in seconds |
Note:
sendQueryRequestis a deprecated alias (deprecated since 2.2.0,forRemoval=trueat v3.0). PrefersendQuery.
subscribeToQueries
void subscribeToQueries(QueriesSubscription subscription) throws KubeMQExceptionSame pattern as commands with query-specific callbacks.
Quick Usage
CommandMessage cmd = CommandMessage.builder()
.channel("svc.commands")
.body(payload)
.timeoutInSeconds(10)
.build();
client.sendCommand(cmd);See Also
Was this page helpful?