KubeMQ
Client SDKsRubyReference

Client

KubeMQ Ruby SDK client classes, constructors, configuration, and lifecycle methods.

The Ruby SDK provides three client classes that inherit shared connection management from BaseClient.

Client Classes

ClassPurpose
KubeMQ::PubSubClientEvents and events store (pub/sub)
KubeMQ::QueuesClientMessage queues (guaranteed delivery)
KubeMQ::CQClientCommands and queries (RPC)

Constructor

All three clients share the same constructor signature inherited from BaseClient:

client = KubeMQ::PubSubClient.new(
  address: "localhost:50000",
  client_id: "my-app",
  auth_token: nil,
  config: nil
)

Parameters

ParameterTypeDefaultDescription
addressString"localhost:50000"Broker host:port
client_idStringAuto-generated UUIDUnique client identifier
auth_tokenStringnilBearer token for authentication
configConfigurationnilPre-built configuration object (overrides individual options)

Lifecycle Methods

ping

Pings the KubeMQ broker and returns server information.

info = client.ping
puts "Host: #{info.host}, Version: #{info.version}"

Returns: ServerInfo with host, version, and server_up_time_seconds attributes.

Raises: ClientClosedError, ConnectionError

close

Closes the client and releases all resources. Idempotent — safe to call multiple times.

client.close
puts client.closed? # => true

closed?

Returns whether the client has been closed.

client.closed? # => true | false

Channel Management

All clients inherit these channel management methods from BaseClient:

create_channel(channel_name:, channel_type:)

Creates a channel on the broker.

client.create_channel(
  channel_name: "my-channel",
  channel_type: KubeMQ::ChannelType::EVENTS
)

delete_channel(channel_name:, channel_type:)

Deletes a channel from the broker.

list_channels(channel_type:, search: nil)

Lists channels of the specified type with optional name filtering.

channels = client.list_channels(
  channel_type: KubeMQ::ChannelType::EVENTS
)
channels.each { |ch| puts ch.name }

Returns: Array<ChannelInfo>

purge_queue_channel(channel_name:)

Purges all messages from a queue channel.

client.purge_queue_channel(channel_name: "tasks")

Convenience Methods

Each client provides type-specific convenience methods:

PubSubClient

MethodDescription
create_events_channel(channel_name:)Create an events channel
create_events_store_channel(channel_name:)Create an events store channel
delete_events_channel(channel_name:)Delete an events channel
delete_events_store_channel(channel_name:)Delete an events store channel
list_events_channels(search: nil)List events channels
list_events_store_channels(search: nil)List events store channels

QueuesClient

MethodDescription
create_queues_channel(channel_name:)Create a queues channel
delete_queues_channel(channel_name:)Delete a queues channel
list_queues_channels(search: nil)List queues channels

CQClient

MethodDescription
create_commands_channel(channel_name:)Create a commands channel
create_queries_channel(channel_name:)Create a queries channel
delete_commands_channel(channel_name:)Delete a commands channel
delete_queries_channel(channel_name:)Delete a queries channel
list_commands_channels(search: nil)List commands channels
list_queries_channels(search: nil)List queries channels

Configuration

Use KubeMQ::Configuration for full control:

config = KubeMQ::Configuration.new(
  address: "broker.example.com:50000",
  client_id: "order-service",
  auth_token: ENV["KUBEMQ_AUTH_TOKEN"],
  tls: KubeMQ::TLSConfig.new(enabled: true, ca_file: "/certs/ca.pem"),
  log_level: :info
)
client = KubeMQ::PubSubClient.new(config: config)

Configuration is resolved in precedence order:

  1. Constructor keyword arguments
  2. Global KubeMQ.configure block
  3. Environment variables (KUBEMQ_ADDRESS, KUBEMQ_AUTH_TOKEN)
  4. Built-in defaults

Was this page helpful?

On this page