Understanding Topics

To understand how messages flow from publishers to subscribers you need to understand the role played by topics in the publish-subscribe model.

What Are Topics?

In an event-driven architecture (EDA), topics are a means for classifying the information contained in the event message. Events are published to a topic and endpoints can subscribe to one or more topics to attract events from publishers. In practice, topics are simply strings composed of one or more levels added to a message header.

Basic Syntax

Topics have the format a/b/c/.../n, where a, b, c and so on to n are identifiers in a hierarchical scheme you've devised that allows you to classify your information. For example, if you're publishing information on household pets you might create topics like animals/domestic/cats and animals/domestic/dogs to organize the content you're sending out.

Topic Subscriptions

A topic subscription is a string used to attract published events. Topic subscriptions can contain wildcards to match with multiple topics. The * and > characters can be used as wildcards in topic subscriptions.

  • *
  • When * appears by itself at a level within a topic subscription it indicates a wildcard match at that level. For example, animals/*/cats matches the topics animals/domestic/cats and animals/wild/cats.

  • >
  • The > character is used at the last level of a subscription to indicate a “one or more” wildcard match for any topics. For example, animals/domestic/> doesn't match the topic animals/domestic, but it does match animals/domestic/cats, animals/domestic/dogs, and animals/domestic/dogs/beagles/long-eared.

To learn more about wildcard rules and their use in topic subscriptions, see Wildcard Characters in Topic Subscriptions.

Topic Destinations

When an event message is published, it is sent to an endpoint that subscribes to the topic. Because the topic is used to specify where the message is received, topics can be thought of as "topic destinations". In other words, the message's destination is a topic rather than something like an IP address, which is a common expectation. Throughout the documentation, publishing is often referred to as "publishing to a topic".

How Event Brokers Use Topics

If we think of topics as destinations, then the event broker can be thought of as the post office that directs events from the publisher to the subscribers' post boxes. Depending on how your EDA and event broker are configured, event brokers use topics to send events to a few types of subscribers:

  • Endpoints—Endpoints are objects created on the event broker to persist messages. There are two types of endpoints: queue endpoints (usually just called queues), and topic endpoints.
    • Queues—A queue is both a destination that clients can publish messages to and an endpoint that clients can consume messages from. Queues that have been configured with topic subscriptions will receive messages with matching topics. A queue is typically used in a point-to-point (PTP) messaging environment. Queues can provide exclusive access to one consumer or access to multiple consumers where each is serviced in a round‑robin fashion.
    • Topic Endpoints—A topic endpoint attracts messages published to a topic for which the topic endpoint has a matching subscription. Any topic endpoints whose topic subscriptions match the topics on the incoming messages will receive those messages.
  • Clients—A client is a consuming application that connects to an event broker. Any of the event broker's clients that have been configured with topic subscriptions will receive messages with matching topics. Access-control lists can govern which topics clients can subscribe to.

Subscribing clients can be bound to destination topic endpoints or queues, or nothing at all. Subscribing clients receive their messages from whatever they're bound to, and if they aren't bound to anything, they can directly receive messages that match the topic subscriptions in their profile.

How Rich Topic Hierarchies Help in an Event Mesh

Smart topics and subscriptions serve various purposes within an event mesh and enable the following benefits when you combine it with a rich topic hierarchy:

Event Routing
The event mesh relies on an event's topic and consumer subscriptions to make routing decisions. Event brokers within a mesh can read the topic and match it to consumer's subscriptions, which describe what kind of data the consumer is interested in. The event topic allows the event broker to make routing decisions without the need for complex understanding of the data encoded in the event's payload.
Event Filtering
Consumers in an event mesh can use subscriptions to have fine-grained control over what data they receive. When combined with a rich topic hierarchy, it allows consumers to receive exactly the data required from the event mesh. Without this fine-grained filtering, consumers may need to discard some of the received data, or an intermediary process would need to re-publish the data to a more specific stream. This filtering is an example of how Solace topics are smart.
Event Access Control
Access control lists (ACLs) allow for administrative management of which events publishers are permitted to produce and which events consumers can receive. This management allows you to control the flow of data both into, and out of an event mesh. When combined with a rich topic hierarchy, you can precisely control the flow of data based on the description of the data in the topic. Lack of precise access control may enable rogue applications to consume privileged information or initiate restricted actions.
Event Handling Policy
You can define policies based on topic subscriptions that handle events within the event broker with respect to priority, eligibility for replay, and replication. The routing from a producer to a consumer can also be influenced using statically-defined bridging policies. With a rich topic hierarchy, administrators can ensure that the right messages are replicated, added to replay logs, etc.
To learn more about building a rich topic hierarchy, see Topic Architecture Best Practices.

Now that you know more about topics, you can learn get more in-depth information about Wildcard Characters in Topic Subscriptions and Topic Architecture Best Practices for designing your EDA.

Or you can learn about how clients receive event messages and how event brokers interact with publishers and clients under Message Delivery Modes.