new_releases 更新:查看
版本说明,了解新功能和产品动态。
RBM 中的同步和异步操作
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本文档阐明了 RBM 平台如何处理消息发送和其他 API 互动,并区分了同步和异步操作。
RBM API 互动通常遵循 HTTP 级别的同步请求-响应模式。不过,许多 API 调用的结果(尤其是消息传送)都是通过 webhook 异步处理的。如需了解详情,请参阅以下部分。
消息发送:同步请求、异步传送
从 API 的角度来看,系统会同步处理 phones.agentMessages.create
API 请求。当您向 RBM 平台发出 HTTP 请求时,服务器几乎会立即响应,并返回标准 HTTP 状态代码(例如 200 OK
或错误),以指明是否已收到请求以及请求是否有效。
不过,系统会异步处理将消息实际传递给最终用户的操作。以下因素可能会影响此过程:
- 收件人状态:用户可能处于离线状态、电池电量耗尽或未启用 RCS。
- 网络状况:运营商网络问题可能会延迟或阻止短信传送。
RBM 平台通过webhooks 异步提供消息传送状态更新(例如传送回执和已读回执)。因此,虽然初始 API 请求是同步的,但您应依赖于异步 webhook 事件来跟踪消息传送情况。请不要指望 phones.agentMessages.create
回复中立即确认递送状态。
其他 RBM API 互动
大多数其他基于 HTTP 的 RBM API 也采用同步请求-响应模型。这些 API 会提供即时 HTTP 响应,指示请求的状态(成功或失败)。不过,虽然请求是同步的,但由请求产生的操作可能涉及异步进程。例如,更新代理信息的 API 调用收到成功响应并不意味着更新会立即反映在所有位置;可能存在短暂的传播延迟。
Webhook 端点:异步事件
以下事件会异步传送到您的webhook端点:
- 传入的用户消息:RBM 平台会将传入的用户消息推送到您的网络钩子端点。请务必验证收到的邮件。
- 送达和已读回执:系统会通过 webhook 发送消息传送和阅读状态通知。
- 对话事件:系统会通过 webhook 发送一些与对话相关的事件,例如打字指示器。
- 消息过期和撤消事件:RBM 平台会发送事件,以确认已过期的邮件是否已成功撤消。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-10。
[null,null,["最后更新时间 (UTC):2025-02-10。"],[[["\u003cp\u003eRBM API interactions use a synchronous request-response model at the HTTP level, providing immediate feedback on request validity.\u003c/p\u003e\n"],["\u003cp\u003eMessage delivery in the RBM platform is processed asynchronously, relying on webhooks for updates due to factors like recipient status and network conditions.\u003c/p\u003e\n"],["\u003cp\u003eWhile the initial API request for sending messages is synchronous, delivery and read receipts are provided asynchronously through webhook events.\u003c/p\u003e\n"],["\u003cp\u003eOther RBM API interactions follow a synchronous pattern for request handling, but resulting actions may involve asynchronous processes with potential delays.\u003c/p\u003e\n"],["\u003cp\u003eThe RBM platform delivers various asynchronous events, such as incoming user messages, delivery receipts, and conversation updates, through a designated webhook endpoint.\u003c/p\u003e\n"]]],[],null,["# Synchronous and asynchronous operations in RBM\n\nThis document clarifies how the RBM platform handles message sending and other\nAPI interactions, distinguishing between synchronous and asynchronous\noperations.\n\nRBM API interactions generally follow a synchronous request-response pattern at\nthe HTTP level. However, the results of many API calls, especially message\ndelivery, are handled asynchronously through webhooks. Refer to the following\nsections for details.\n\nMessage sending: Synchronous request, asynchronous delivery\n-----------------------------------------------------------\n\nThe [`phones.agentMessages.create`](/business-communications/rcs-business-messaging/reference/rest/v1/phones.agentMessages/create)\nAPI request is processed **synchronously** from the API\nperspective. When you make an HTTP request to the RBM platform, the server\nresponds almost immediately with a standard HTTP status code\n(like `200 OK` or an error) to indicate whether the request was\nreceived and is valid.\n\nHowever, the actual delivery of the message to the end user is\nprocessed **asynchronously**. The following factors can affect this process:\n\n- **Recipient status**: The user might be offline, have an empty battery, or not have RCS enabled.\n- **Network conditions**: Carrier network issues can delay or prevent message delivery.\n\nThe RBM platform provides message delivery status updates (like delivery\nreceipts and read receipts) asynchronously through\n[webhooks](/business-communications/rcs-business-messaging/guides/integrate/webhooks).\nTherefore, while the initial API request is synchronous, you should rely on\nasynchronous webhook [events](/business-communications/rcs-business-messaging/guides/build/events#agent-generated_events)\nto track message delivery. Don't expect immediate confirmation of delivery\nstatus from the\n[`phones.agentMessages.create`](/business-communications/rcs-business-messaging/reference/rest/v1/phones.agentMessages/create)\nresponse.\n\n### Other RBM API interactions\n\nMost other HTTP-based RBM APIs also operate with a synchronous request-response\nmodel. These APIs provide an immediate HTTP response that indicates the status\nof the request (success or error). However, while the request is synchronous,\nthe actions resulting from the request might involve asynchronous processes.\nFor example, a successful response to an API call to update agent information\ndoesn't mean the update is instantly reflected everywhere; there might be a\nshort propagation delay.\n\nWebhook endpoint: Asynchronous events\n-------------------------------------\n\nThe following [events](/business-communications/rcs-business-messaging/guides/build/events#agent-generated_events)\nare delivered asynchronously to your [webhook](/business-communications/rcs-business-messaging/guides/integrate/webhooks)\nendpoint:\n\n- **Incoming user messages** : The RBM platform pushes incoming user messages to your webhook endpoint. Be sure to [verify incoming messages](/business-communications/rcs-business-messaging/guides/integrate/webhooks#verify_incoming_messages).\n- **Delivery and read receipts**: Notifications of message delivery and read status are sent through webhooks.\n- **Conversation events**: Some conversation-related events, such as typing indicators, are sent through webhooks.\n- **Message expiration and revocation events**: The RBM platform sends events to confirm whether an expired message was successfully revoked."]]