diff --git a/sdk/servicebus/service-bus/samples/javascript/receiveMessagesStreaming.js b/sdk/servicebus/service-bus/samples/javascript/receiveMessagesStreaming.js index c6332a2e3730..de53757968f1 100644 --- a/sdk/servicebus/service-bus/samples/javascript/receiveMessagesStreaming.js +++ b/sdk/servicebus/service-bus/samples/javascript/receiveMessagesStreaming.js @@ -2,19 +2,13 @@ Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT Licence. - This sample demonstrates how the receive() function can be used to receive Service Bus messages + This sample demonstrates how the registerMessageHandler() function can be used to receive Service Bus messages in a stream. Setup: Please run "sendMessages.ts" sample before running this to populate the queue/topic */ -const { - OnMessage, - OnError, - ServiceBusClient, - ReceiveMode, - MessagingError -} = require("@azure/service-bus"); +const { ServiceBusClient, ReceiveMode } = require("@azure/service-bus"); // Load the .env file if it exists const dotenv = require("dotenv"); @@ -46,11 +40,11 @@ async function main() { }; const onErrorHandler = (err) => { - if (err.retryable === false) { - console.log("Receiver will be recreated. A fatal error occurred:", err); + if (err.retryable === true) { + console.log("Receiver will be recreated. A recoverable error occurred:", err); resolve(); } else { - console.log("Non-fatal error occurred: ", err); + console.log("Error occurred: ", err); } }; diff --git a/sdk/servicebus/service-bus/samples/typescript/src/receiveMessagesStreaming.ts b/sdk/servicebus/service-bus/samples/typescript/src/receiveMessagesStreaming.ts index 25cbad550e58..05b9d3ee4160 100644 --- a/sdk/servicebus/service-bus/samples/typescript/src/receiveMessagesStreaming.ts +++ b/sdk/servicebus/service-bus/samples/typescript/src/receiveMessagesStreaming.ts @@ -2,7 +2,7 @@ Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT Licence. - This sample demonstrates how the receive() function can be used to receive Service Bus messages + This sample demonstrates how the registerMessageHandler() function can be used to receive Service Bus messages in a stream. Setup: Please run "sendMessages.ts" sample before running this to populate the queue/topic @@ -46,11 +46,11 @@ export async function main() { }; const onErrorHandler: OnError = (err) => { - if ((err as MessagingError).retryable === false) { - console.log("Receiver will be recreated. A fatal error occurred:", err); + if ((err as MessagingError).retryable === true) { + console.log("Receiver will be recreated. A recoverable error occurred:", err); resolve(); } else { - console.log("Non-fatal error occurred: ", err); + console.log("Error occurred: ", err); } };