Google Cloud Pub/Sub
从 Delphi 发布和拉取 Google Cloud Pub/Sub 主题中的消息。服务账号 JWT 签名以及类型化的 Publish / Pull / Acknowledge 方法。
从 Delphi 发布和拉取 Google Cloud Pub/Sub 主题中的消息。服务账号 JWT 签名以及类型化的 Publish / Pull / Acknowledge 方法。
Google Cloud Pub/Sub REST 客户端 — 从类型化的 Delphi 组件创建主题、发布消息、从订阅拉取、确认或修改确认截止时间。
TsgcHTTPGoogleCloud_PubSub_Client
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
加载服务账号 JSON,设置项目 ID,然后调用 Publish 发送消息,Pull 从订阅中消费。
uses
sgcHTTP;
var
PubSub: TsgcHTTPGoogleCloud_PubSub_Client;
begin
PubSub := TsgcHTTPGoogleCloud_PubSub_Client.Create(nil);
PubSub.GoogleCloudOptions.ServiceAccountJSON.LoadFromFile('service-account.json');
// publish
PubSub.Publish('projects/your-project/topics/topic-id',
'{"event":"order_created","id":42}');
// pull
Memo1.Text := PubSub.Pull('projects/your-project/subscriptions/sub-id', 10);
end;
// uses: sgcHTTP
TsgcHTTPGoogleCloud_PubSub_Client *PubSub = new TsgcHTTPGoogleCloud_PubSub_Client(this);
PubSub->GoogleCloudOptions->ServiceAccountJSON->LoadFromFile("service-account.json");
PubSub->Publish("projects/p/topics/t", payload);
Memo1->Text = PubSub->Pull("projects/p/subscriptions/s", 10);
封装了 Pub/Sub REST 接口,使用标准的 Google 服务账号认证流程。
CreateTopic, DeleteTopic, GetTopic, ListTopics hit the /projects/<id>/topics endpoint family.
Publish 发送一条或多条带可选属性和排序键的 PubsubMessage,返回分配的 messageIds。
Pull(subscription, maxMessages) 返回带有 ackId 的已接收消息;Acknowledge(subscription, ackIds) 完成确认,ModifyAckDeadline 延长处理时间。
与 FCM 和 Calendar 兄弟组件相同的认证流程 — 加载 JSON 密钥,签署 RS256 JWT,换取 OAuth 令牌,按需刷新。
CreateSubscription, DeleteSubscription, UpdateSubscription, ListSubscriptions manage the subscription side of Pub/Sub.
拉取订阅使用 Pull 读取;推送订阅配置为调用您的端点 — 通常是公网 URL 后面的 TsgcWebSocketHTTPServer 实例。
本组件所实现 API 的权威来源。