KubeMQ
Client SDKsJavaReference

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 KubeMQException

Sends a command and blocks until a worker responds or the timeout elapses.

Parameters:

NameTypeRequiredDescription
messageCommandMessageYesChannel, body/metadata, timeoutInSeconds, tags

Returns: CommandResponseMessage — execution metadata and payload.

Note: sendCommandRequest is a deprecated alias (deprecated since 2.2.0, forRemoval=true at v3.0). Prefer sendCommand.

subscribeToCommands

void subscribeToCommands(CommandsSubscription subscription) throws KubeMQException

Registers a consumer that returns CommandResponseMessage from the handler callback.

CommandsSubscription fields:

FieldTypeDescription
channelStringChannel to listen on
groupStringConsumer group
onReceiveCommandCallbackConsumer<CommandMessageReceived>Handler
onErrorCallbackConsumer<KubeMQException>Error hook

Queries

sendQuery

QueryResponseMessage sendQuery(QueryMessage message) throws KubeMQException

QueryMessage extends CommandMessage with:

FieldTypeDescription
cacheKeyStringCache key for response reuse
cacheTtlInSecondsintTTL in seconds

Note: sendQueryRequest is a deprecated alias (deprecated since 2.2.0, forRemoval=true at v3.0). Prefer sendQuery.

subscribeToQueries

void subscribeToQueries(QueriesSubscription subscription) throws KubeMQException

Same pattern as commands with query-specific callbacks.

Quick Usage

Rpc.java
CommandMessage cmd = CommandMessage.builder()
    .channel("svc.commands")
    .body(payload)
    .timeoutInSeconds(10)
    .build();

client.sendCommand(cmd);

See Also

Was this page helpful?

On this page