Skip to content

Commit bbbfa39

Browse files
Merge pull request #267011 from mattchenderson/sb-autocomplete
Updates to Service Bus message auto-completion
2 parents cb7a916 + 1c45fc3 commit bbbfa39

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

articles/azure-functions/functions-bindings-service-bus-trigger.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ The following table explains the properties you can set using this trigger attri
370370
|**Connection**| The name of an app setting or setting collection that specifies how to connect to Service Bus. See [Connections](#connections).|
371371
|**IsBatched**| Messages are delivered in batches. Requires an array or collection type. |
372372
|**IsSessionsEnabled**|`true` if connecting to a [session-aware](../service-bus-messaging/message-sessions.md) queue or subscription. `false` otherwise, which is the default value.|
373+
|**AutoCompleteMessages**| `true` if the trigger should automatically complete the message after a successful invocation. `false` if it should not, such as when you are [handling message settlement in code](#usage). If not explicitly set, the behavior will be based on the [`autoCompleteMessages` configuration in `host.json`][host-json-autoComplete].|
373374

374375
# [In-process model](#tab/in-process)
375376

@@ -590,9 +591,16 @@ Poison message handling can't be controlled or configured in Azure Functions. Se
590591

591592
## PeekLock behavior
592593

593-
The Functions runtime receives a message in [PeekLock mode](../service-bus-messaging/service-bus-performance-improvements.md#receive-mode). It calls `Complete` on the message if the function finishes successfully, or calls `Abandon` if the function fails. If the function runs longer than the `PeekLock` timeout, the lock is automatically renewed as long as the function is running.
594+
The Functions runtime receives a message in [PeekLock mode](../service-bus-messaging/service-bus-performance-improvements.md#receive-mode).
594595

595-
The `maxAutoRenewDuration` is configurable in *host.json*, which maps to [ServiceBusProcessor.MaxAutoLockRenewalDuration](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.maxautolockrenewalduration). The default value of this setting is 5 minutes.
596+
::: zone pivot="programming-language-javascript,programming-language-typescript,programming-language-java,programming-language-python,programming-language-powershell"
597+
By default, the runtime calls `Complete` on the message if the function finishes successfully, or calls `Abandon` if the function fails. You can disable automatic completion through with the [`autoCompleteMessages` property in `host.json`][host-json-autoComplete].
598+
::: zone-end
599+
::: zone pivot="programming-language-csharp"
600+
By default, the runtime calls `Complete` on the message if the function finishes successfully, or calls `Abandon` if the function fails. You can disable automatic completion through with the [`autoCompleteMessages` property in `host.json`][host-json-autoComplete] or through a [property on the trigger attribute](#attributes). You should disable automatic completion if your function code handles message settlement.
601+
::: zone-end
602+
603+
If the function runs longer than the `PeekLock` timeout, the lock is automatically renewed as long as the function is running. The `maxAutoRenewDuration` is configurable in *host.json*, which maps to [ServiceBusProcessor.MaxAutoLockRenewalDuration](/dotnet/api/azure.messaging.servicebus.servicebusprocessor.maxautolockrenewalduration). The default value of this setting is 5 minutes.
596604

597605
::: zone pivot="programming-language-csharp"
598606
## Message metadata
@@ -696,3 +704,4 @@ Functions version 1.x doesn't support isolated worker process. To use the isolat
696704

697705

698706
[upgrade your application to Functions 4.x]: ./migrate-version-1-version-4.md
707+
[host-json-autoComplete]: ./functions-bindings-service-bus.md#hostjson-settings

articles/azure-functions/functions-bindings-service-bus.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ The `clientRetryOptions` settings only apply to interactions with the Service Bu
261261
|**maxDelay**|`00:01:00`|The maximum delay to allow between retry attempts|
262262
|**maxRetries**|`3`|The maximum number of retry attempts before considering the associated operation to have failed.|
263263
|**prefetchCount**|`0`|Gets or sets the number of messages that the message receiver can simultaneously request.|
264-
| **transportType**| amqpTcp | The protocol and transport that is used for communicating with Service Bus. Available options: `amqpTcp`, `amqpWebSockets`|
265-
| **webProxy**| n/a | The proxy to use for communicating with Service Bus over web sockets. A proxy cannot be used with the `amqpTcp` transport. |
266-
|**autoCompleteMessages**|`true`|Determines whether or not to automatically complete messages after successful execution of the function and should be used in place of the `autoComplete` configuration setting.|
264+
|**transportType**| amqpTcp | The protocol and transport that is used for communicating with Service Bus. Available options: `amqpTcp`, `amqpWebSockets`|
265+
|**webProxy**| n/a | The proxy to use for communicating with Service Bus over web sockets. A proxy cannot be used with the `amqpTcp` transport. |
266+
|**autoCompleteMessages**|`true`|Determines whether or not to automatically complete messages after successful execution of the function.|
267267
|**maxAutoLockRenewalDuration**|`00:05:00`|The maximum duration within which the message lock will be renewed automatically. This setting only applies for functions that receive a single message at a time.|
268268
|**maxConcurrentCalls**|`16`|The maximum number of concurrent calls to the callback that should be initiated per scaled instance. By default, the Functions runtime processes multiple messages concurrently. This setting is used only when the `isSessionsEnabled` property or attribute on [the trigger](functions-bindings-service-bus-trigger.md) is set to `false`. This setting only applies for functions that receive a single message at a time.|
269269
|**maxConcurrentSessions**|`8`|The maximum number of sessions that can be handled concurrently per scaled instance. This setting is used only when the `isSessionsEnabled` property or attribute on [the trigger](functions-bindings-service-bus-trigger.md) is set to `true`. This setting only applies for functions that receive a single message at a time.|

includes/functions-bindings-service-bus-trigger-dotnet-isolated-types.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ When you want the function to process a single message, the Service Bus trigger
1313
| `string` | The message as a string. Use when the message is simple text. |
1414
| `byte[]` | The bytes of the message. |
1515
| JSON serializable types | When an event contains JSON data, Functions tries to deserialize the JSON data into a plain-old CLR object (POCO) type. |
16-
| [ServiceBusReceivedMessage]<sup>1</sup> | The message object.<br/><br/>When binding to `ServiceBusReceivedMessage`, you can optionally also include a parameter of type [ServiceBusMessageActions]<sup>1</sup> to perform [message settlement] actions.|
16+
| [ServiceBusReceivedMessage]<sup>1</sup> | The message object.<br/><br/>When binding to `ServiceBusReceivedMessage`, you can optionally also include a parameter of type [ServiceBusMessageActions]<sup>1,2</sup> to perform [message settlement] actions.|
1717

1818
When you want the function to process a batch of messages, the Service Bus trigger can bind to the following types:
1919

2020
| Type | Description |
2121
| --- | --- |
22-
| `T[]` where `T` is one of the single message types | An array of events from the batch. Each entry represents one event.<br/><br/>When binding to `ServiceBusReceivedMessage[]`, you can optionally also include a parameter of type [ServiceBusMessageActions]<sup>1</sup> to perform [message settlement] actions.|
22+
| `T[]` where `T` is one of the single message types | An array of events from the batch. Each entry represents one event.<br/><br/>When binding to `ServiceBusReceivedMessage[]`, you can optionally also include a parameter of type [ServiceBusMessageActions]<sup>1,2</sup> to perform [message settlement] actions.|
2323

2424
<sup>1</sup> To use these types, you need to reference [Microsoft.Azure.Functions.Worker.Extensions.ServiceBus 5.14.1 or later](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.ServiceBus/5.14.1) and the [common dependencies for SDK type bindings](../articles/azure-functions/dotnet-isolated-process-guide.md#sdk-types).
2525

26+
<sup>2</sup> When using `ServiceBusMessageActions`, set the [`AutoCompleteMessages` property of the trigger attribute](../articles/azure-functions/functions-bindings-service-bus-trigger.md#attributes) to `false`. This prevents the runtime from attempting to complete messages after a successful function invocation.
27+
2628
[ServiceBusReceivedMessage]: /dotnet/api/azure.messaging.servicebus.servicebusreceivedmessage
2729
[ServiceBusMessageActions]: https://github.com/Azure/azure-functions-dotnet-worker/blob/main/extensions/Worker.Extensions.ServiceBus/src/ServiceBusMessageActions.cs
2830
[message settlement]: ../articles/service-bus-messaging/message-transfers-locks-settlement.md#peeklock

0 commit comments

Comments
 (0)