Creating Topics

When using the JCSM, Java RTO, and Javascript, Node.js, or .NET APIs (which are object-oriented), a client must create a Topic instance to encapsulate a topic name that can be used as a destination to publish messages to. Topic instances can also be used by consumers to indicate through subscriptions what messages they are interested in receiving.

In the C (not object-oriented) where a topic is simply a string (char*).

When using the JavaScript and Node.js APIs, a generic Destination instance is created and used instead of a Topic instance.

Clients can create:

  • Non-temporary Topics at the factory level.
  • Temporary Topics at the Session level. The scope and lifetime of a temporary Topic is that of the Session it is created in.

For information on the supported Topic syntax rules, refer to Topic Support & Syntax.

When using the C API, a Topic is simply set as a destination message property (refer to Destination).


To create a Topic (non-temporary), call one of the methods listed below on a connected Session and pass in a topic name.

To Create Topics

PubSub+ Messaging API Use


  • JCSMPFactory.createTopic(...)
  • DestinationUtils.topicFromNetworkName(...)

Java RTO

  • Solclient.Allocator.NewTopic(...)


  • No function, a topic is a char* (string).


  • ContextFactory.createTopic(...)

  • Helper.Destination.TopicFromEncodedName(...)

JavaScript and Node.js

  • solace.SolClientFactory.createTopicDestination(...)

Temporary Topics

To create a temporary Topic, call one of the listed methods on a connected Session. A temporary Topic’s physical name is automatically generated by the API.

A temporary Topic can only be created on a connected Session.

When using JCSMP, a connection automatically occurs when the first operation is performed on the Session. Therefore, it is recommended that another operation (for example, adding a subscription) is performed before attempting to create a temporary Topic, as this establishes the necessary connection.

To Create Temporary Topics

PubSub+ Messaging API Use

JCSMP (legacy Solace Java API)


Java RTO






JavaScript and Node.js

Not applicable

Related Samples

For an example of how to create Topics and temporary Topics, refer to the SimpleFlowToTopic samples for the JCSMP, Java RTO, and .NET APIs.