Creating Topics

When using the Solace Java RTO API, Solace JavaScript API, Solace Node.js API, or Solace .NET API (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 Solace C API (not object-oriented) where a topic is simply a string (char*).

When using the Solace JavaScript API and Solace Node.js API, 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 Solace C API, a topic is simply set as a destination message property (refer to Destination).

Topics

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

Solace Messaging API Use

Solace Java RTO API

  • Solclient.Allocator.NewTopic(...)

Solace C API

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

Solace .NET API

  • ContextFactory.createTopic(...)

  • Helper.Destination.TopicFromEncodedName(...)

Solace JavaScript API and Solace Node.js API

  • 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.

To Create Temporary Topics

Solace Messaging API Use

Solace Java RTO API

SessionHandle.createTemporaryTopic()

Solace C API

solClient_session_createTemporaryTopicName()

Solace .NET API

ISession.createTemporaryTopic()

Solace JavaScript API and Solace Node.js API

Not applicable

Related Samples

For an example of how to create topics and temporary topics, refer to the SimpleFlowToTopic samples for the Solace Java RTO API and Solace .NET API.