managing-managed-event-subscription
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseManaging ManagedEventSubscription
管理ManagedEventSubscription
Create, read, update, and delete metadata — the Salesforce construct for durably subscribing to platform event channels with managed replay tracking.
ManagedEventSubscription创建、读取、更新和删除元数据——这是Salesforce中用于通过托管重放跟踪持久订阅平台事件通道的结构。
ManagedEventSubscriptionScope
适用范围
- In scope: Generating and modifying files for create, read, update, and delete operations
.managedEventSubscription-meta.xml - Out of scope: Creating the underlying platform event () channel itself; Flow-based or Apex-based event subscriptions; deploying metadata to an org
__e - Only generate one file — the file. Do NOT generate the referenced platform event object or any other metadata type.
.managedEventSubscription-meta.xml
- 包含范围:生成和修改文件以执行创建、读取、更新和删除操作
.managedEventSubscription-meta.xml - 排除范围:创建底层平台事件()通道;基于Flow或Apex的事件订阅;将元数据部署到组织
__e - 仅生成一个文件——文件。请勿生成引用的平台事件对象或任何其他元数据类型。
.managedEventSubscription-meta.xml
Clarifying Questions
澄清问题
Before generating, confirm if not already clear:
- What is the topic name? (see format table in )
references/topic-name-formats.md - What is the developer name? (required for Create — alphanumeric and underscores only, no spaces; optional for Read/Update/Delete if is known)
Id - What is the label (human-readable name)?
- What default replay preset — (default) or
LATEST?EARLIEST - What error recovery replay preset — (default) or
LATEST?EARLIEST - What should the initial state be — (active) or
RUN(inactive)? (default:STOP)RUN
在生成之前,若尚未明确请确认:
- 主题名称是什么?(请查看中的格式表格)
references/topic-name-formats.md - 开发者名称是什么?(创建操作必填——仅允许字母数字和下划线,不能有空格;若已知,读取/更新/删除操作可选)
Id - 标签(人类可读名称)是什么?
- 默认重放预设是(默认)还是
LATEST?EARLIEST - 错误恢复重放预设是(默认)还是
LATEST?EARLIEST - 初始状态应该是(激活)还是
RUN(停用)?(默认:STOP)RUN
Required Inputs
必填输入
Gather or infer before proceeding:
- Operation: create, read, update, or delete
- DeveloperName: required for Create (becomes the filename); optional for Read/Update/Delete if is provided instead
Id - Id: Tooling API record Id — can be used to identify the subscription for Read/Update/Delete instead of DeveloperName
- label: human-readable label (can include spaces)
- topicName: event channel path — read for valid formats (platform events, change events, custom channels)
references/topic-name-formats.md - defaultReplay: or
LATEST(default:EARLIEST)LATEST - errorRecoveryReplay: or
LATEST(default:EARLIEST)LATEST - state: or
RUN(default:STOP) —RUNis reserved for internal platform use and will be rejected withPAUSEINVALID_INPUT - version: Metadata API version (default: match org API version, e.g. )
67.0
开始前需收集或推断以下信息:
- 操作类型:创建、读取、更新或删除
- DeveloperName:创建操作必填(将作为文件名);若提供,读取/更新/删除操作可选
Id - Id:Tooling API记录ID——可替代DeveloperName用于识别读取/更新/删除操作的订阅
- label:人类可读标签(可包含空格)
- topicName:事件通道路径——请阅读获取有效格式(平台事件、变更事件、自定义通道)
references/topic-name-formats.md - defaultReplay:或
LATEST(默认:EARLIEST)LATEST - errorRecoveryReplay:或
LATEST(默认:EARLIEST)LATEST - state:或
RUN(默认:STOP)——RUN为平台内部保留使用,会被PAUSE拒绝INVALID_INPUT - version:Metadata API版本(默认:匹配组织API版本,例如)
67.0
Workflow
工作流程
Create
创建
- Gather inputs — confirm DeveloperName, label, topicName, defaultReplay, errorRecoveryReplay, state, version. Apply defaults for any omitted fields. If DeveloperName is not provided, ask the user — do not derive it from the label.
- Confirm the topic exists — ask the user to confirm the event channel already exists in the org before proceeding. Do NOT generate the platform event object yourself — that is out of scope for this skill. If the user says it doesn't exist yet, stop and direct them to create it first using the skill, then return here.
generating-platform-event - Read the template — load as the starting structure.
assets/managed-event-subscription-template.xml - Generate the file — produce filled with user-provided values.
managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml - Verify — run the checklist below before presenting output.
- Guide the user on subscribing — after deployment, the subscription can be identified for Pub/Sub API RPC calls using either the
ManagedSubscribeor the recordDeveloperName. To retrieve theId, run:Idvia the Tooling API.SELECT Id, DeveloperName FROM ManagedEventSubscription WHERE DeveloperName='<DeveloperName>'
- 收集输入——确认DeveloperName、label、topicName、defaultReplay、errorRecoveryReplay、state、version。对遗漏字段应用默认值。若未提供DeveloperName,请询问用户——不要从label推导。
- 确认主题存在——请用户确认事件通道已在组织中存在后再继续。请勿自行生成平台事件对象——这超出了本技能的范围。如果用户表示通道尚未存在,请停止操作并引导其先使用技能创建,之后再返回此处。
generating-platform-event - 读取模板——加载作为初始结构。
assets/managed-event-subscription-template.xml - 生成文件——生成填充了用户提供值的文件。
managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml - 验证——在呈现输出前运行下方的检查清单。
- 指导用户订阅——部署完成后,可通过或记录
DeveloperName在Pub/Sub API的IdRPC调用中识别该订阅。若要获取ManagedSubscribe,请通过Tooling API执行:Id。SELECT Id, DeveloperName FROM ManagedEventSubscription WHERE DeveloperName='<DeveloperName>'
Read
读取
- Identify the subscription — accept either or
Id; preferDeveloperNameif provided.Id - Show the file path — (if DeveloperName known).
managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml - Retrieve and display — read and present the current XML content.
- 识别订阅——接受或
Id;若同时提供优先使用DeveloperName。Id - 显示文件路径——(若已知DeveloperName)。
managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml - 检索并展示——读取并呈现当前XML内容。
Update
更新
- Identify the subscription — accept either or
Id; preferDeveloperNameif provided.Id - Read the existing file — load current content before modifying.
- Apply changes — update only the specified fields; preserve all others.
- Read for fields that cannot be changed after creation.
references/update-constraints.md - Verify — run the checklist below before presenting output.
- 识别订阅——接受或
Id;若同时提供优先使用DeveloperName。Id - 读取现有文件——修改前加载当前内容。
- 应用变更——仅更新指定字段;保留所有其他字段。
- **阅读**了解创建后无法修改的字段。
references/update-constraints.md - 验证——在呈现输出前运行下方的检查清单。
Delete
删除
- Identify the subscription — accept either or
Id; confirm with the user before proceeding.DeveloperName - Warn — deleting a ManagedEventSubscription permanently removes replay tracking state.
- Produce deletion instructions — explain how to remove the file and deploy the destructive change using .
destructiveChanges.xml - Read for the destructive deployment procedure.
references/delete-guide.md
- 识别订阅——接受或
Id;执行前请与用户确认。DeveloperName - 警告——删除ManagedEventSubscription会永久移除重放跟踪状态。
- 生成删除说明——解释如何移除文件并通过部署破坏性变更。
destructiveChanges.xml - **阅读**获取破坏性部署流程。
references/delete-guide.md
Rules / Constraints
规则/约束
| Constraint | Rationale |
|---|---|
| Platform events use |
| These are the only valid enum values; any other value fails metadata validation |
| |
| All six required elements must be present | |
| DeveloperName must be unique within the org | Duplicate names cause |
Do not include | Read-only platform fields; including them causes deployment failures in unpackaged orgs |
| 约束 | 理由 |
|---|---|
| 平台事件使用 |
| 这些是唯一有效的枚举值;任何其他值都会导致元数据验证失败 |
| |
| 必须包含所有六个必填元素 | |
| DeveloperName在组织内必须唯一 | 重复名称会导致 |
请勿包含 | 这些是平台只读字段;在未打包组织中包含它们会导致部署失败 |
Gotchas
常见问题
| Issue | Resolution |
|---|---|
| Wrong format or the event doesn't exist in the org — read |
| Replay state lost after delete + recreate | Deleting discards stored replay position; recreating starts from |
| ManagedEventSubscription is only queryable via Tooling API, not standard SOQL |
| Can trigger up to 72 hours of backlog replay on activation; always confirm with the user |
| Metadata not supported in older orgs | ManagedEventSubscription requires API v60.0+; check org API version |
| These are wrong field names — use |
| |
| User unsure how to identify subscription for Pub/Sub API | Both |
| Changes not reflected immediately in Pub/Sub API | After create/update/delete, the Pub/Sub API can take up to ~2 minutes to reflect the new config; if ManagedSubscribe returns NOT_FOUND, wait and retry |
| 问题 | 解决方案 |
|---|---|
部署时提示 | 格式错误或事件在组织中不存在——请阅读 |
| 删除后重新创建导致重放状态丢失 | 删除操作会丢弃存储的重放位置;重新创建会从 |
SOQL查询时提示 | ManagedEventSubscription仅可通过Tooling API查询,无法通过标准SOQL查询 |
高容量通道使用 | 激活时可能触发长达72小时的积压重放;请务必与用户确认 |
| 旧版本组织不支持该元数据 | ManagedEventSubscription需要API v60.0+;请检查组织API版本 |
生成的XML中包含 | 这些是错误的字段名称——请使用 |
生成的XML中包含 | |
| 用户不确定如何在Pub/Sub API中识别订阅 | |
| 变更未立即在Pub/Sub API中生效 | 创建/更新/删除后,Pub/Sub API最多可能需要2分钟才能反映新配置;若ManagedSubscribe返回NOT_FOUND,请等待并重试 |
Verification Checklist
验证清单
Before presenting any generated XML:
- Does follow a valid path format per
<topicName>? (references/topic-name-formats.md,/event/Name__e,/data/NameChangeEvent,/data/ChangeEvents,/event/Name__chn)/data/Name__chn - Is exactly
<defaultReplay>orLATEST?EARLIEST - Is exactly
<errorRecoveryReplay>orLATEST?EARLIEST - Is exactly
<state>orRUN? (STOPis invalid for user-created subscriptions)PAUSE - Is populated?
<label> - Is present (e.g.
<version>)?67.0 - Are read-only fields (,
<id>,<createdDate>) absent?<namespacePrefix> - Does the filename match the DeveloperName exactly?
在呈现任何生成的XML前:
- 是否遵循
<topicName>中的有效路径格式?(例如references/topic-name-formats.md、/event/Name__e、/data/NameChangeEvent、/data/ChangeEvents、/event/Name__chn)/data/Name__chn - 是否恰好为
<defaultReplay>或LATEST?EARLIEST - 是否恰好为
<errorRecoveryReplay>或LATEST?EARLIEST - 是否恰好为
<state>或RUN?(STOP对用户创建的订阅无效)PAUSE - 是否已填充?
<label> - 是否存在(例如
<version>)?67.0 - 是否不存在只读字段(、
<id>、<createdDate>)?<namespacePrefix> - 文件名是否与DeveloperName完全匹配?
Output Expectations
输出预期
- Create / Update: — this is the only file to generate
managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml - Delete: instructions to remove the file and deploy via
destructiveChanges.xml - Read: display of existing file contents
- 创建/更新:——这是唯一需要生成的文件
managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml - 删除:移除文件并通过部署的说明
destructiveChanges.xml - 读取:现有文件内容的展示
Cross-Skill Integration
跨技能集成
| Need | Delegate to |
|---|---|
Create the platform event channel ( | |
| Subscribe via Flow (Process Automation) | |
| Deploy metadata to org | |
| 需求 | 委托至 |
|---|---|
创建要订阅的平台事件通道( | |
| 通过Flow(流程自动化)订阅 | |
| 将元数据部署到组织 | |
Reference File Index
参考文件索引
| File | When to read |
|---|---|
| Before generating any new subscription — use as starting structure |
| When setting |
| During Update workflow — to check which fields are immutable post-creation |
| During Delete workflow — for destructive change deployment procedure |
| 文件 | 阅读时机 |
|---|---|
| 生成任何新订阅之前——用作初始结构 |
| 设置 |
| 更新工作流程期间——检查哪些字段在创建后不可变 |
| 删除工作流程期间——获取破坏性变更部署流程 |