Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.93k stars 441 forks source link

Expose API to set visibilitytimeout and TTL for individual queue messages #4176

Open rixw opened 5 years ago

rixw commented 5 years ago

Investigative information

Timestamp: 08-03-2019 17:30Z Function App version (1.0 or 2.0): 2.0.12332.0 Function App name: rixwscrape Function name(s) (as appropriate): enqueue Invocation ID: Region: UK South

Repro steps

The Queue Storage output binding allows the configuration of a global or per function visibilityTimeout for retries of failed messages, but no means of setting this programatically for the initial visibilityTimeout per message. All that can be specified is the message body.

Expected behavior

To be specify a queue item as an object, rather than a plain string. Something like:

context.bindings.myQueueItem = [ { message: "message 1", visibilityTimeout: 30, messageTimeToLive: 3600 }, { message: "message 2", visibilityTimeout: 60, messageTimeToLive: 3600 }, ];

Actual behavior

Not supported

Known workarounds

I can achieve what I need to do by using the @azure/storage-queue SDK: https://docs.microsoft.com/en-us/javascript/api/%40azure/storage-queue/messagesurl?view=azure-node-preview#enqueue-aborter--string--messagesenqueueoptionalparams-

messagesUrl.enqueue(Aborter.none, JSON.stringify(result, undefined, 2), { visibilitytimeout: 30, messageTimeToLive: 3600 }),

But it would be way more developer-friendly if these options could be specified via an output binding - I've got c 20 quite verbose LOC at the moment which could be 2-3.

atoko commented 4 years ago

Is this something that can still be looked at? It would be great to schedule a queue item for processing in the future via output binding

prenaissance commented 1 year ago

bumped, I'm surprised this is missing from the v4 programming model too.

earloc commented 1 year ago

Would also love to see this

rixw commented 1 year ago

I agree with @prenaissance that the v4 programming model feels like an ideal opportunity to introduce this.

merrickheley commented 11 months ago

Also agree, I'd love to configure this per-message in the python output bindings

@app.function_name(name="Example")
@app.schedule(schedule="0 0 */4 * * *", arg_name="myTimer")
@app.queue_output(arg_name="msg", queue_name=queue_name, connection="AzureWebJobsStorage")
def some_function(myTimer: func.TimerRequest, msg: func.Out[typing.List[str]]) -> None:
    msg.set("Example", time_to_live=60)