MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.2k stars 21.35k forks source link

lockToken #62830

Open jmbertucci opened 3 years ago

jmbertucci commented 3 years ago

I found the Message Metadata section helpful in knowing what WebJob params I can add.

However, one important pieces seems to be missing the lockToken property which I found in a response in the following issue:

https://github.com/Azure/azure-webjobs-sdk/issues/1986

To be able to manually mange the message with Complete, Abandon or DeadLetter we need the lock token.

An example might be:

[FunctionName("Processing")]
public async Task Process(
    [ServiceBusTrigger("Queue Name", Connection = "Connection")] string message, 
    MessageReceiver messageReceiver,
    string lockToken
)
{
  // ...
  await messageReciever.DeadLetterAsync(lockToken, "reason", "description");
  // or
  await messageReciever.CompleteAsync(lockToken);
  // or
  await messageReciever.AbandonAsync(lockToken);
 // ...
}

In general, my use case really only called for "short circuiting" the DeadLetter process (instead of retrying 'x' times). But either way, getting the right lockToken is non-optional but it's not documented as a metadata on this page.

This was the best page I could find at this point (I've spent too many hours trying to figure this out) so hopefully it can help others our.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ChaitanyaNaykodi-MSFT commented 3 years ago

Hello @jmbertucci, Thank you for your feedback! We have assigned this issue to the author to review further and take the next course of action.

wjohnson commented 3 years ago

@craigshoemaker - Does this still fall under your purview? I'm trying to leverage the lock token in the Java SDK but I cannot get it out of there for the life of me. Knowing the correct documentation for the lock token would be very helpful.

fowl2 commented 2 years ago

Azure functions (v5) will bind a parameter of type ServiceBusMessageActions (or ServiceBusSessionMessageActions if you're using sessions) that has methods accept a ServiceBusReceivedMessage

I'm sure I read this in the docs but I can only find this now: https://docs.microsoft.com/en-us/dotnet/api/overview/azure/microsoft.azure.webjobs.extensions.servicebus-readme-pre#message-settlement