【问题标题】:How can I set the expiration (TTL) for a queue message with the Azure Storage Queue Logic App connector?如何使用 Azure 存储队列逻辑应用连接器设置队列消息的过期 (TTL)?
【发布时间】:2019-04-03 14:40:44
【问题描述】:

在我的逻辑应用中,我看不到设置队列消息的 TTL 或到期日期的方法。

但从 UI 中是可能的,所以我知道 API 可以做到:

我什至尝试将 messagettl 查询字符串参数“破解”到代码视图中:

"actions": {
    "Put_a_message_on_a_queue": {
        "inputs": {
            "body": "@{base64(items('For_each'))}",
            "host": {
                "connection": {
                    "name": "@parameters('$connections')['azurequeues']['connectionId']"
                }
            },
            "method": "post",
            "path": "/@{encodeURIComponent('updateuser')}/messages?messagettl=3600"
        },
        "runAfter": {},
        "type": "ApiConnection"
    }
}

但我得到一个错误:

{
 "message": "Unable to match incoming request to an operation."
}

【问题讨论】:

    标签: azure azure-logic-apps azure-api-apps azure-storage-queues


    【解决方案1】:

    我通过查看对 Azure 门户中的添加队列消息 UI 进行的 API 调用发现了这一点。它附加了一个查询字符串参数messagettl,它是秒 TTL。

    所以,我查看了架构here,发现您可以将"queries": {...} 对象传递给HTTP 调用以添加消息。

    最终代码查看 JSON:

    "actions": {
        "Put_a_message_on_a_queue": {
            "inputs": {
                "body": "@{base64(items('For_each'))}",
                "host": {
                    "connection": {
                        "name": "@parameters('$connections')['azurequeues']['connectionId']"
                    }
                },
                "method": "post",
                "path": "/@{encodeURIComponent('updateuser')}/messages",
                "queries": {
                    "messagettl": 3600
                }
            },
            "runAfter": {},
            "type": "ApiConnection"
        }
    }
    

    【讨论】:

    • 在逻辑应用弃用旧调度程序后,我迁移到了它们。我忘记了 TTL,我的一堆工作并没有像批处理器周末停机时那样过期。啊。至少我现在不必滚动我自己的方法/功能/操作来将项目添加到队列中。谢谢!
    • 设置 messagettl = -1 是否按照本文档中的说明工作?我无法让它发挥作用。 docs.microsoft.com/en-us/rest/api/storageservices/put-message。错误:请求 URI 中指定的查询参数之一超出允许范围。最小允许 1;最大允许 604800
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 2021-04-24
    • 2022-10-08
    • 2019-04-18
    相关资源
    最近更新 更多