Choose topic or subscription SMTs

Single message transforms (SMTs) can be set as properties of topics or subscriptions.

  • A topic SMT applies transformations to the messages before the messages are persisted for a topic.

  • A subscription SMT applies transformations to the messages before the messages are delivered to a subscription.

The following are some reasons for applying an SMT to a topic instead of a subscription:

  • You want multiple subscriptions on the same topic to receive the transformed message. If all subscriptions on a topic are supposed to receive the transformed message, then it is better to apply the transformation one time on the publish side.

  • You want to minimize storage, inter-region delivery, and subscriber delivery costs. If you remove unnecessary fields from a message using an SMT defined on a topic, then all subsequent data processing and delivery operations benefit from the reduced message footprint.

  • You want to handle invalid messages at publish time. If you use an SMT on a topic to validate messages, then any publish with an invalid message is going to fail. You can decide in the publisher how to handle these failures.

The following are some reasons for applying an SMT to a subscription instead of a topic:

  • You only need transformations for a single subscription. A subscription SMT is useful when you only need transformations for a single subscription.

  • You want to write invalid messages to a dead-letter topic. You can also use subscription SMTs with dead-letter topics to archive failed transformations. The errors result in messages being routed to the designated dead-letter topic.

You can combine topic and subscription SMTs to perform independent transformations on a single message.

What's next