Skip to content

Commit 993c7bc

Browse files
authored
[Service Bus] autoComplete -> autoCompleteMessages (Azure#12558)
1 parent e8b73af commit 993c7bc

File tree

15 files changed

+49
-49
lines changed

15 files changed

+49
-49
lines changed

sdk/servicebus/service-bus/review/service-bus.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ export interface SqlRuleFilter {
488488

489489
// @public
490490
export interface SubscribeOptions extends OperationOptionsBase {
491-
autoComplete?: boolean;
491+
autoCompleteMessages?: boolean;
492492
maxConcurrentCalls?: number;
493493
}
494494

sdk/servicebus/service-bus/samples/javascript/advanced/deferral.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ async function receiveMessage() {
111111
receiver.subscribe(
112112
{ processMessage, processError },
113113
{
114-
autoComplete: false
114+
autoCompleteMessages: false
115115
}
116-
); // Disabling autoComplete so we can control when message can be completed, deferred or deadlettered
116+
); // Disabling autoCompleteMessages so we can control when message can be completed, deferred or deadlettered
117117
await delay(10000);
118118
await receiver.close();
119119
console.log("Total number of deferred messages:", deferredSteps.size);

sdk/servicebus/service-bus/samples/javascript/receiveMessagesStreaming.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,15 @@ async function main() {
3030

3131
try {
3232
const subscription = receiver.subscribe({
33+
// After executing this callback you provide, the receiver will remove the message from the queue if you
34+
// have not already settled the message in your callback.
35+
// You can disable this by passing `false` to the `autoCompleteMessages` option in the `subscribe()` method.
36+
// If your callback _does_ throw an error before the message is settled, then it will be abandoned.
3337
processMessage: async (brokeredMessage) => {
3438
console.log(`Received message: ${brokeredMessage.body}`);
35-
36-
// autoComplete, which is enabled by default, will automatically call
37-
// receiver.completeMessage() on your message after awaiting on your processMessage
38-
// handler so long as your handler does not throw an error.
39-
//
40-
// If your handler _does_ throw an error then the message will automatically
41-
// be abandoned using receiver.abandonMessage()
42-
//
43-
// autoComplete can be disabled in the options for subscribe().
4439
},
40+
// This callback will be called for any error that occurs when either in the receiver when receiving the message
41+
// or when executing your `processMessage` callback or when the receiver automatically completes or abandons the message.
4542
processError: async (args) => {
4643
console.log(`Error from source ${args.errorSource} occurred: `, args.error);
4744

sdk/servicebus/service-bus/samples/typescript/src/advanced/deferral.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ async function receiveMessage() {
117117
receiver.subscribe(
118118
{ processMessage, processError },
119119
{
120-
autoComplete: false
120+
autoCompleteMessages: false
121121
}
122-
); // Disabling autoComplete so we can control when message can be completed, deferred or deadlettered
122+
); // Disabling autoCompleteMessages so we can control when message can be completed, deferred or deadlettered
123123
await delay(10000);
124124
await receiver.close();
125125
console.log("Total number of deferred messages:", deferredSteps.size);

sdk/servicebus/service-bus/samples/typescript/src/receiveMessagesStreaming.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,15 @@ export async function main() {
3838

3939
try {
4040
const subscription = receiver.subscribe({
41+
// After executing this callback you provide, the receiver will remove the message from the queue if you
42+
// have not already settled the message in your callback.
43+
// You can disable this by passing `false` to the `autoCompleteMessages` option in the `subscribe()` method.
44+
// If your callback _does_ throw an error before the message is settled, then it will be abandoned.
4145
processMessage: async (brokeredMessage: ServiceBusReceivedMessage) => {
4246
console.log(`Received message: ${brokeredMessage.body}`);
43-
44-
// autoComplete, which is enabled by default, will automatically call
45-
// receiver.completeMessage() on your message after awaiting on your processMessage
46-
// handler so long as your handler does not throw an error.
47-
//
48-
// If your handler _does_ throw an error then the message will automatically
49-
// be abandoned using receiver.abandonMessage()
50-
//
51-
// autoComplete can be disabled in the options for subscribe().
5247
},
48+
// This callback will be called for any error that occurs when either in the receiver when receiving the message
49+
// or when executing your `processMessage` callback or when the receiver automatically completes or abandons the message.
5350
processError: async (args: ProcessErrorArgs) => {
5451
console.log(`Error from source ${args.errorSource} occurred: `, args.error);
5552

sdk/servicebus/service-bus/src/core/messageReceiver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ export abstract class MessageReceiver extends LinkEntity<Receiver> {
162162
this.receiveMode = options.receiveMode || "peekLock";
163163

164164
// If explicitly set to false then autoComplete is false else true (default).
165-
this.autoComplete = options.autoComplete === false ? options.autoComplete : true;
165+
this.autoComplete =
166+
options.autoCompleteMessages === false ? options.autoCompleteMessages : true;
166167
this._lockRenewer = options.lockRenewer;
167168
}
168169

sdk/servicebus/service-bus/src/models.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,16 @@ export interface GetMessageIteratorOptions extends OperationOptionsBase {}
154154
*/
155155
export interface SubscribeOptions extends OperationOptionsBase {
156156
/**
157-
* @property Indicates whether the `complete()` method on the message should automatically be
158-
* called by the sdk after the user provided onMessage handler has been executed.
159-
* Calling `complete()` on a message removes it from the Queue/Subscription.
157+
* @property Indicates whether the message should be settled using the `completeMessage()`
158+
* method on the receiver automatically after it executes the user provided message callback.
159+
* Doing so removes the message from the queue/subscription.
160+
*
161+
* This option is ignored if messages are received in the `receiveAndDelete` receive mode or if
162+
* the message is already settled in the user provided message callback.
163+
*
160164
* - **Default**: `true`.
161165
*/
162-
autoComplete?: boolean;
166+
autoCompleteMessages?: boolean;
163167
/**
164168
* @property The maximum number of concurrent calls that the library
165169
* can make to the user's message handler. Once this limit has been reached, more messages will

sdk/servicebus/service-bus/src/receivers/receiver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ export class ServiceBusReceiverImpl implements ServiceBusReceiver {
425425
options: StreamingReceiverInitArgs
426426
): Promise<StreamingReceiver> {
427427
throwErrorIfConnectionClosed(this._context);
428-
if (options.autoComplete == null) options.autoComplete = true;
428+
if (options.autoCompleteMessages == null) options.autoCompleteMessages = true;
429429

430430
// When the user "stops" a streaming receiver (via the returned instance from 'subscribe' we just suspend
431431
// it, leaving the link open). This allows users to stop the flow of messages but still be able to settle messages

sdk/servicebus/service-bus/src/session/messageSession.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ export class MessageSession extends LinkEntity<Receiver> {
603603
}
604604

605605
// If explicitly set to false then autoComplete is false else true (default).
606-
this.autoComplete = options.autoComplete === false ? options.autoComplete : true;
606+
this.autoComplete =
607+
options.autoCompleteMessages === false ? options.autoCompleteMessages : true;
607608
this._onMessage = onMessage;
608609
this._onError = onError;
609610

sdk/servicebus/service-bus/test/receiveAndDeleteMode.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe("receive and delete", () => {
145145
errors.push(args.error.message);
146146
}
147147
},
148-
{ autoComplete: autoCompleteFlag }
148+
{ autoCompleteMessages: autoCompleteFlag }
149149
);
150150

151151
const msgsCheck = await checkWithTimeout(() => receivedMsgs.length === 1);

0 commit comments

Comments
 (0)