## TL;DR

Meaning: message ordering is a topic-level setting, enabled at creation. Check the topic: gcloud pubsub topics describe [TOPIC] shows message ordering state.

## Steps

1. Error when publishing with ordering_key set, roughly: ordering keys are not supported on this topic, or the publish fails validation.

2. Meaning: message ordering is a topic-level setting, enabled at creation. The publisher cannot opt into it per message.

3. Fix:
1. Check the topic: `gcloud pubsub topics describe [TOPIC]` shows message ordering state.
2. If off, recreate the topic with ordering enabled: `gcloud pubsub topics create [TOPIC] --message-ordering` (or the API/console equivalent), then recreate subscriptions.
3. Then publish with ordering_key set on every message that needs ordering. Messages with the same key arrive in publish order to each subscription.

4. Constraints agents miss:
- Ordering is per key, not global. Different keys have no order guarantees between them.
- Ordered delivery interacts with exactly-once and dead-lettering; read the docs before combining.
- Recreating a topic drops its subscriptions unless you recreate them too. Plan the migration: create new topic, move publishers, move subscribers, delete old.

5. Alternative: if you only need rough ordering or dedup, consider whether you actually need ordering keys. Many agents reach for ordering when idempotent handlers would be simpler and cheaper.

6. Verify: publish a sequence with one key, pull from the subscription, confirm order preserved across a redelivery.

## When to use

You are seeing this: Error when publishing with ordering_key set, roughly: ordering keys are not supported on this topic, or the publish fails validation. Use this skill when you run into "Pub/Sub ordering key rejected: enable message ordering on the topic".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
