diff --git a/sdk/storage/storage-queue/recordings/browsers/queueclient_messageid_methods/recording_update_visibility_timeout_only_preserve_content.json b/sdk/storage/storage-queue/recordings/browsers/queueclient_messageid_methods/recording_update_visibility_timeout_only_preserve_content.json new file mode 100644 index 000000000000..6f34c8b84fee --- /dev/null +++ b/sdk/storage/storage-queue/recordings/browsers/queueclient_messageid_methods/recording_update_visibility_timeout_only_preserve_content.json @@ -0,0 +1,109 @@ +{ + "recordings": [ + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue160015813770703540", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 201, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Tue, 15 Sep 2020 08:22:18 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "f4a8c0d7-254b-4a9a-bcba-a84695fa1804", + "x-ms-request-id": "59bd2c3b-2003-0066-5839-8bed2f000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "POST", + "url": "https://fakestorageaccount.queue.core.windows.net/queue160015813770703540/messages", + "query": { + "visibilitytimeout": "10", + "timeout": "30" + }, + "requestBody": "foo", + "status": 201, + "response": "56947312-751e-4eda-8024-ad7da71ba8b7Tue, 15 Sep 2020 08:22:19 GMTTue, 22 Sep 2020 08:22:19 GMTAgAAAAMAAAAAAAAAi/40WjmL1gE=Tue, 15 Sep 2020 08:22:29 GMT", + "responseHeaders": { + "content-type": "application/xml", + "date": "Tue, 15 Sep 2020 08:22:18 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding": "chunked", + "x-ms-client-request-id": "d960f306-0c71-4a7a-9df2-62c1430af19b", + "x-ms-request-id": "59bd31c8-2003-0066-4c39-8bed2f000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "PUT", + "url": "https://fakestorageaccount.queue.core.windows.net/queue160015813770703540/messages/56947312-751e-4eda-8024-ad7da71ba8b7", + "query": { + "popreceipt": "AgAAAAMAAAAAAAAAi/40WjmL1gE=", + "visibilitytimeout": "0", + "timeout": "30" + }, + "requestBody": null, + "status": 204, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Tue, 15 Sep 2020 08:22:19 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "cbbb8c81-d74d-43b5-b10b-6653888b4a87", + "x-ms-popreceipt": "AwAAAAMAAAAAAAAALjGbVDmL1gEAAAAA", + "x-ms-request-id": "59bd373d-2003-0066-2a39-8bed2f000000", + "x-ms-time-next-visible": "Tue, 15 Sep 2020 08:22:20 GMT", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "GET", + "url": "https://fakestorageaccount.queue.core.windows.net/queue160015813770703540/messages", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 200, + "response": "56947312-751e-4eda-8024-ad7da71ba8b7Tue, 15 Sep 2020 08:22:19 GMTTue, 22 Sep 2020 08:22:19 GMTAgAAAAMAAAAAAAAATSTYZjmL1gE=Tue, 15 Sep 2020 08:22:50 GMT1foo", + "responseHeaders": { + "cache-control": "no-cache", + "content-type": "application/xml", + "date": "Tue, 15 Sep 2020 08:22:20 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "transfer-encoding": "chunked", + "x-ms-client-request-id": "05f0472a-ac7a-4f51-a804-13f6e3cb4229", + "x-ms-request-id": "59bd3c34-2003-0066-6539-8bed2f000000", + "x-ms-version": "2020-02-10" + } + }, + { + "method": "DELETE", + "url": "https://fakestorageaccount.queue.core.windows.net/queue160015813770703540", + "query": { + "timeout": "30" + }, + "requestBody": null, + "status": 204, + "response": "", + "responseHeaders": { + "content-length": "0", + "date": "Tue, 15 Sep 2020 08:22:20 GMT", + "server": "Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "78d4e21d-c50d-4de0-afa0-9e71c060b65f", + "x-ms-request-id": "59bd4256-2003-0066-5239-8bed2f000000", + "x-ms-version": "2020-02-10" + } + } + ], + "uniqueTestInfo": { + "uniqueName": { + "queue": "queue160015813770703540" + }, + "newDate": {} + }, + "hash": "c97a331f5a4027e071f910b9d305ee79" +} \ No newline at end of file diff --git a/sdk/storage/storage-queue/recordings/node/queueclient_messageid_methods/recording_update_visibility_timeout_only_preserve_content.js b/sdk/storage/storage-queue/recordings/node/queueclient_messageid_methods/recording_update_visibility_timeout_only_preserve_content.js new file mode 100644 index 000000000000..e380815a6e55 --- /dev/null +++ b/sdk/storage/storage-queue/recordings/node/queueclient_messageid_methods/recording_update_visibility_timeout_only_preserve_content.js @@ -0,0 +1,109 @@ +let nock = require('nock'); + +module.exports.hash = "e43fe88599f94bda7bb7c36a7c88b62f"; + +module.exports.testInfo = {"uniqueName":{"queue":"queue160015809428209607"},"newDate":{}} + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .put('/queue160015809428209607') + .query(true) + .reply(201, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2248f401-9003-003e-1b39-8b3570000000', + 'x-ms-client-request-id', + '243c19b3-a611-47c4-bb86-6f342d4f2ae3', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Tue, 15 Sep 2020 08:21:35 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .post('/queue160015809428209607/messages', "foo") + .query(true) + .reply(201, "a340c68f-fd60-484d-bf95-14ce7ec15614Tue, 15 Sep 2020 08:21:35 GMTTue, 22 Sep 2020 08:21:35 GMTAgAAAAMAAAAAAAAAPV0YQDmL1gE=Tue, 15 Sep 2020 08:21:45 GMT", [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2248f4d8-9003-003e-5839-8b3570000000', + 'x-ms-client-request-id', + '9e7e431a-ac04-4522-8322-fe56a306f5a0', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Tue, 15 Sep 2020 08:21:35 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .put('/queue160015809428209607/messages/a340c68f-fd60-484d-bf95-14ce7ec15614') + .query(true) + .reply(204, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2248f5af-9003-003e-1c39-8b3570000000', + 'x-ms-client-request-id', + '08bc98dd-c44f-4b4b-a4ab-47f81b0ae7fc', + 'x-ms-version', + '2020-02-10', + 'x-ms-popreceipt', + 'AwAAAAMAAAAAAAAAyudQOjmL1gEAAAAA', + 'x-ms-time-next-visible', + 'Tue, 15 Sep 2020 08:21:36 GMT', + 'Date', + 'Tue, 15 Sep 2020 08:21:36 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .get('/queue160015809428209607/messages') + .query(true) + .reply(200, "a340c68f-fd60-484d-bf95-14ce7ec15614Tue, 15 Sep 2020 08:21:35 GMTTue, 22 Sep 2020 08:21:35 GMTAgAAAAMAAAAAAAAAywtgTDmL1gE=Tue, 15 Sep 2020 08:22:06 GMT1foo", [ + 'Cache-Control', + 'no-cache', + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/xml', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2248f673-9003-003e-4f39-8b3570000000', + 'x-ms-client-request-id', + '61f2ddc4-b4dd-47bc-9af2-4d587dafe80a', + 'x-ms-version', + '2020-02-10', + 'Access-Control-Expose-Headers', + 'x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,Content-Type,Cache-Control,Content-Length,Date,Transfer-Encoding', + 'Access-Control-Allow-Origin', + '*', + 'Date', + 'Tue, 15 Sep 2020 08:21:36 GMT' +]); + +nock('https://fakestorageaccount.queue.core.windows.net:443', {"encodedQueryParams":true}) + .delete('/queue160015809428209607') + .query(true) + .reply(204, "", [ + 'Content-Length', + '0', + 'Server', + 'Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0', + 'x-ms-request-id', + '2248f71b-9003-003e-6e39-8b3570000000', + 'x-ms-client-request-id', + 'c084add0-1a55-4435-aff2-cd8c2298deaf', + 'x-ms-version', + '2020-02-10', + 'Date', + 'Tue, 15 Sep 2020 08:21:36 GMT' +]); diff --git a/sdk/storage/storage-queue/review/storage-queue.api.md b/sdk/storage/storage-queue/review/storage-queue.api.md index 6a23acf8805e..57ec1be8fcbf 100644 --- a/sdk/storage/storage-queue/review/storage-queue.api.md +++ b/sdk/storage/storage-queue/review/storage-queue.api.md @@ -370,7 +370,7 @@ export class QueueClient extends StorageClient { sendMessage(messageText: string, options?: QueueSendMessageOptions): Promise; setAccessPolicy(queueAcl?: SignedIdentifier[], options?: QueueSetAccessPolicyOptions): Promise; setMetadata(metadata?: Metadata, options?: QueueSetMetadataOptions): Promise; - updateMessage(messageId: string, popReceipt: string, message: string, visibilityTimeout?: number, options?: QueueUpdateMessageOptions): Promise; + updateMessage(messageId: string, popReceipt: string, message?: string, visibilityTimeout?: number, options?: QueueUpdateMessageOptions): Promise; } // @public diff --git a/sdk/storage/storage-queue/src/QueueClient.ts b/sdk/storage/storage-queue/src/QueueClient.ts index 22bed59a583a..9f19867a8613 100644 --- a/sdk/storage/storage-queue/src/QueueClient.ts +++ b/sdk/storage/storage-queue/src/QueueClient.ts @@ -1271,18 +1271,21 @@ export class QueueClient extends StorageClient { public async updateMessage( messageId: string, popReceipt: string, - message: string, + message?: string, visibilityTimeout?: number, options: QueueUpdateMessageOptions = {} ): Promise { const { span, spanOptions } = createSpan("QueueClient-updateMessage", options.tracingOptions); + let queueMessage = undefined; + if (message) { + queueMessage = { messageText: message }; + } + try { return await this.getMessageIdContext(messageId).update(popReceipt, visibilityTimeout || 0, { abortSignal: options.abortSignal, spanOptions, - queueMessage: { - messageText: message - } + queueMessage }); } catch (e) { span.setStatus({ diff --git a/sdk/storage/storage-queue/test/messageidclient.spec.ts b/sdk/storage/storage-queue/test/messageidclient.spec.ts index eae5d21d32b2..d27d268afffe 100644 --- a/sdk/storage/storage-queue/test/messageidclient.spec.ts +++ b/sdk/storage/storage-queue/test/messageidclient.spec.ts @@ -206,4 +206,13 @@ describe("QueueClient messageId methods", () => { ); assert.equal(newClient.name, queueName, "Queue name is not the same as the one provided."); }); + + it("update visibility timeout only preserve content", async () => { + const message = "foo"; + const enqueueRes = await queueClient.sendMessage(message, { visibilityTimeout: 10 }); + await queueClient.updateMessage(enqueueRes.messageId, enqueueRes.popReceipt); + const receiveMessage = (await queueClient.receiveMessages()).receivedMessageItems[0]; + assert.equal(enqueueRes.messageId, receiveMessage.messageId); + assert.equal(message, receiveMessage.messageText); + }); });