简体   繁体   English

如何设置队列输出的到期时间-Azure Function JS

[英]How to set expiration time for queue output - Azure function js

How to set a expiration time for queue message as output in azure function 如何在azure函数中设置队列消息的到期时间作为输出

    {
      "type": "queue",
      "name": "outputQueueItem",
      "queueName": "myqueue",
      "connection": "AzureWebJobsStorage",
      "direction": "out"
    }
context.bindings.outputQueueItem = "message";

I am not aware using using nodejs 我不知道使用nodejs

But with c# , below is the sample 但是使用c#,下面是示例

Change the type of your parameter to CloudQueue, then add a message manually and set the expiration time property (or rather Time To Live). 将参数的类型更改为CloudQueue,然后手动添加消息并设置到期时间属性(或更确切地说是生存时间)。

 public static void Run(string input, CloudQueue outputQueue) { outputQueue.AddMessage( new CloudQueueMessage("Hello " + input), TimeSpan.FromMinutes(5)); } 

if your output queue name depends on request, you can use imperative binding: 如果您的输出队列名称取决于请求,则可以使用命令式绑定:

 public static void Run(string input, IBinder binder) { string outputQueueName = "outputqueue " + input; QueueAttribute queueAttribute = new QueueAttribute(outputQueueName); CloudQueue outputQueue = binder.Bind<CloudQueue>(queueAttribute); outputQueue.AddMessage( new CloudQueueMessage("Hello " + input), TimeSpan.FromMinutes(5)); } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM