php - Yii2 - WebService API 和队列
问题描述
我正在使用 yiisoft/yii2-httpclient 扩展来使用 Web 服务。我有一个控制器可以在 web 服务中创建新记录。出于任何原因,操作创建可能会失败(超时、ws 已关闭等)如果记录失败,则将此操作创建放入队列(如 yiisoft/yii2-queue)中是正确的,在后台重试?
控制器.php
public function actionCreate()
{
$client = new Client();
$response = $client->createRequest()
->setMethod('POST')
->setUrl('http://******/rooms')
->setData([
'name' => $model->name,
'date' => $model->date,
])
->send();
if ($response->isOk) {
return $this->redirect(['index']);
}
}
解决方案
推荐阅读
- gremlin - 将 Gremlin 查询压缩为一个
- html - 用于 mat-table 的 HTML 中的角度材料错误
- odoo - 如何删除列表视图中的默认“分组依据”选项(odoo12)
- python - 创建 Tkinter 按钮的列表或字典以在不同的框架中使用
- react-native - React Native - 如何从 Expo 中的 TaskManager 访问承诺值?
- c# - C# linq 查询 - 如何使用值列表查询内部表
- android - 如何在 Android Room 中使用 ExecutorService?
- git - 我从 GitHub 克隆了存储库,但我的本地克隆存储库中缺少提交
- java - 使用 java-netbeans 在电报机器人上发送粗体文本
- reactjs - React - 如何控制导出/导入限制