Skip to content

Solace interface examples


The scripts below are in the examples folder of the interface. They provide insight into the different capabilities of the interface.


  1. The Solace interface installed as described in the interface’s
  2. The folder q/ containing solace.q placed either in the examples folder or (preferably) in the your QHOME directory.


Pass parameters to the scripts as command-line arguments. Default values for all parameters are set in sol_init.q.

-corr   correlation ID
-data   message payload to send
-dest   name of endpoint queue to use or create
-dtype  type of destination: [queue (default) | topic]
-host   SMF host URI (e.g. tcps://
-name   name of the endpoint to create
-pass   password
-queue  name of the exiting queue endpoint to alter
-topic  topic name  (Solace wildcard format supported)
-user   username
-vpn    VPN name
-trust  trust store i.e. directory containing Solace PEM file (when using secure SMF host connection)
-opt    session capability

General utilities

API version

q sol_version.q

Prints the Solace API version currently in use

Query broker capabilities

q sol_capabilities.q -opt SESSION_PEER_SOFTWARE_VERSION \
    -host tcps:// \
    -user solace -pass ggut5 -vpn test -trust cert

Command-line arguments: -host -vpn -trust -user -pass -name -opt

Requests capability value from the Solace broker. A list of capabilities are provided here

Endpoint interactions

Create a queue

q sol_endpoint_create.q <args>

Command-line arguments: -host -vpn -trust -user -pass -name

Creates a queue on a Solace PubSub+ broker, subject to permission.

q sol_endpoint_create.q -name "Q/test"

Remove an endpoint

q sol_endpoint_destroy.q <args>

Command-line arguments: -host -vpn -trust -user -pass -name

Removes an existing endpoint on the Solace broker, subject to permission.

q sol_endpoint_destroy.q -name "Q/test"

Add a topic subscription to a queue

q sol_topic_to_queue_mapping.q <args>

Command-line arguments: -host -vpn -trust -user -pass -queue -topic

Adds a topic subscription to an existing endpoint queue, subject to permission.

q sol_topic_to_queue_mapping.q -queue "Q/test" -topic "Q/topic"

Pub/sub with direct messages

Send a direct message via a topic

q sol_pub_direct.q <args>

Command-line arguments: -host -vpn -trust -user -pass -topic -data

This can be used in conjunction with sol_sub_direct.q or any Solace example program.

q sol_pub_direct.q -topic "Q/1" -data "hello world"

Subscribe to a topic for direct messages

q sol_sub_direct.q <args>

Command-line arguments: -host -vpn -trust -user -pass -topic

q sol_sub_direct.q -host tcp:// -topic "Q/>"

Send a direct message via a topic, request a reply

q sol_pub_directrequestor.q <args>

Command-line arguments: -host -vpn -trust -user -pass -topic -data

Sends a direct message via a topic, and requests a reply as part of the published message.

This can be used in conjunction with sol_sub_directreplier.q or any Solace example program.

q sol_pub_directrequestor.q -topic "Q/1" -data "hello world"

Subscribe to a topic for direct messages, replying

q sol_sub_directrequestor.q <args>

Command-line arguments: -host -vpn -trust -user -pass -topic

Subscribes to a topic for the consumption of direct messages, replying to any message received.

q sol_sub_directreplier.q -host tcp:// -topic "Q/>"

Pub/sub with guaranteed messages

Send a persistent or guaranteed message

q sol_pub_persist.q <args>

Command-line arguments: -host -vpn -trust -user -pass -data -dtype -dest -corr

Sends a persistent or guaranteed message to an existing endpoint.

(See sol_endpoint_create.q.)

q sol_pub_persist.q -dtype "queue" -dest "Q/1" -data "hello world" -corr 555

Subscribe while printing and acknowledging each message

q sol_sub_persist.q <args>

Command-line arguments: -host -vpn -trust -user -pass -dest

q sol_sub_persist.q -dest "Q/1"
Back to top