KubeMQ
Client SDKsRustReference

RPC

Command, Query, response types, and request-response operations

Command

Outbound command request. The sender blocks until a subscriber responds or the timeout expires.

FieldTypeDefaultDescription
idStringUUID v4Request identifier
channelStringrequiredTarget channel name
metadataString""Optional metadata
bodyVec<u8>[]Command payload
timeoutDuration5sMaximum wait for response
client_idString""Sender identity override
tagsHashMap{}Key-value pairs

Builder

main.rs
use std::time::Duration;

let cmd = Command::builder()
    .channel("device.reboot")
    .body(b"device-42".to_vec())
    .timeout(Duration::from_secs(10))
    .build();

CommandResponse

Returned by send_command.

FieldTypeDescription
command_idStringOriginal command request ID
response_client_idStringIdentity of the handler
executedboolWhether the command succeeded
executed_ati64Server timestamp
errorStringError message when executed is false
tagsHashMapHandler-attached tags

CommandReceive / CommandReply

CommandReceive is delivered to the subscription callback. Use CommandReply::builder() to construct the response.

main.rs
let reply = CommandReply::builder()
    .request_id(&cmd.id)
    .response_to(&cmd.response_to)
    .build();
client.send_command_response(reply).await?;

Query

Outbound query request with optional server-side caching.

FieldTypeDefaultDescription
idStringUUID v4Request identifier
channelStringrequiredTarget channel name
metadataString""Optional metadata
bodyVec<u8>[]Query payload
timeoutDuration5sMaximum wait for response
cache_keyString""Cache key (empty disables caching)
cache_ttlDuration0Cache time-to-live
tagsHashMap{}Key-value pairs

Builder

main.rs
use std::time::Duration;

let query = Query::builder()
    .channel("inventory.lookup")
    .body(b"sku-12345".to_vec())
    .timeout(Duration::from_secs(10))
    .cache_key("sku-12345")
    .cache_ttl(Duration::from_secs(60))
    .build();

QueryResponse

Returned by send_query.

FieldTypeDescription
query_idStringOriginal query request ID
executedboolWhether the query succeeded
metadataStringResponse metadata
bodyVec<u8>Response payload
cache_hitboolWhether served from cache
errorStringError message when executed is false

Client Methods

send_command / send_query

main.rs
let resp = client.send_command(cmd).await?;
let resp = client.send_query(query).await?;

subscribe_to_commands / subscribe_to_queries

main.rs
let sub = client.subscribe_to_commands("channel", "", handler, None).await?;
let sub = client.subscribe_to_queries("channel", "", handler, None).await?;

send_command_response / send_query_response

main.rs
client.send_command_response(reply).await?;
client.send_query_response(reply).await?;

Was this page helpful?

On this page