[servicebus]scheduleMessages method swap enqueedTime and messages order (#11994)

Co-authored-by: Mohsin Mehmood <mohsin85mehmod@gmail.com>
This commit is contained in:
Mohsin Mehmood 2020-10-23 03:33:17 +08:00 коммит произвёл GitHub
Родитель 0dd578545b
Коммит f58d9256cb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 26 добавлений и 25 удалений

Просмотреть файл

@ -31,6 +31,7 @@
- "properties" renamed to "applicationProperties"
- "label" renamed to "subject"
- `SqlRuleFilter` interface "sqlExpression" changed from optional to required
- `ServiceBusSender.scheduleMessages` method signature updated: `scheduledEnqueueTimeUtc` and `messages` parameters are swapped.
## 7.0.0-preview.7 (2020-10-07)

Просмотреть файл

@ -468,7 +468,7 @@ export interface ServiceBusSender {
entityPath: string;
isClosed: boolean;
open(options?: OperationOptionsBase): Promise<void>;
scheduleMessages(scheduledEnqueueTimeUtc: Date, messages: ServiceBusMessage | ServiceBusMessage[], options?: OperationOptionsBase): Promise<Long[]>;
scheduleMessages(messages: ServiceBusMessage | ServiceBusMessage[], scheduledEnqueueTimeUtc: Date, options?: OperationOptionsBase): Promise<Long[]>;
sendMessages(messages: ServiceBusMessage | ServiceBusMessage[] | ServiceBusMessageBatch, options?: OperationOptionsBase): Promise<void>;
}

Просмотреть файл

@ -89,8 +89,8 @@ export interface ServiceBusSender {
/**
* Schedules given messages to appear on Service Bus Queue/Subscription at a later time.
*
* @param scheduledEnqueueTimeUtc - The UTC time at which the messages should be enqueued.
* @param messages - Message or an array of messages that need to be scheduled.
* @param scheduledEnqueueTimeUtc - The UTC time at which the messages should be enqueued.
* @param options - Options bag to pass an abort signal or tracing options.
* @returns Promise<Long[]> - The sequence numbers of messages that were scheduled.
* You will need the sequence number if you intend to cancel the scheduling of the messages.
@ -100,8 +100,8 @@ export interface ServiceBusSender {
* @throws MessagingError if the service returns an error while scheduling messages.
*/
scheduleMessages(
scheduledEnqueueTimeUtc: Date,
messages: ServiceBusMessage | ServiceBusMessage[],
scheduledEnqueueTimeUtc: Date,
options?: OperationOptionsBase
): Promise<Long[]>;
@ -244,8 +244,8 @@ export class ServiceBusSenderImpl implements ServiceBusSender {
}
async scheduleMessages(
scheduledEnqueueTimeUtc: Date,
messages: ServiceBusMessage | ServiceBusMessage[],
scheduledEnqueueTimeUtc: Date,
options: OperationOptionsBase = {}
): Promise<Long[]> {
this._throwIfSenderOrConnectionClosed();

Просмотреть файл

@ -77,9 +77,9 @@ describe("sender unit tests", () => {
try {
await sender.scheduleMessages(
new Date(),
// @ts-expect-error
invalidValue
invalidValue,
new Date()
);
} catch (err) {
assert.equal(err.name, "TypeError");

Просмотреть файл

@ -399,7 +399,7 @@ describe("invalid parameters", () => {
it("ScheduledMessages: Missing messages in Sender", async function(): Promise<void> {
let caughtError: Error | undefined;
try {
await sender.scheduleMessages(new Date(), undefined as any);
await sender.scheduleMessages(undefined as any, new Date());
} catch (error) {
caughtError = error;
}

Просмотреть файл

@ -78,8 +78,8 @@ describe("ManagementClient - disconnects", function(): void {
// Send a message so we have something to peek.
const deliveryIds = await sender.scheduleMessages(
new Date("2020-04-25T12:00:00Z"),
TestMessage.getSample()
TestMessage.getSample(),
new Date("2020-04-25T12:00:00Z")
);
deliveryIds.length.should.equal(1, "Unexpected number of scheduled messages.");
@ -97,8 +97,8 @@ describe("ManagementClient - disconnects", function(): void {
// peek additional messages
const [deliveryId] = await sender.scheduleMessages(
new Date("2020-04-25T12:00:00Z"),
TestMessage.getSample()
TestMessage.getSample(),
new Date("2020-04-25T12:00:00Z")
);
deliveryIds.push(deliveryId);
deliveryIds.length.should.equal(2, "Unexpected number of scheduled messages.");

Просмотреть файл

@ -102,7 +102,7 @@ describe("Retries - ManagementClient", () => {
it("Unpartitioned Queue: scheduleMessages", async function(): Promise<void> {
await beforeEachTest(TestClientType.UnpartitionedQueue);
await mockManagementClientAndVerifyRetries(async () => {
await sender.scheduleMessages(new Date(), [TestMessage.getSample()]);
await sender.scheduleMessages([TestMessage.getSample()], new Date());
});
});

Просмотреть файл

@ -155,7 +155,7 @@ describe("Sender Tests", () => {
: TestMessage.getSample();
const scheduleTime = new Date(Date.now() + 10000); // 10 seconds from
await sender.scheduleMessages(scheduleTime, testMessage);
await sender.scheduleMessages(testMessage, scheduleTime);
const msgs = await receiver.receiveMessages(1);
const msgEnqueueTime = msgs[0].enqueuedTimeUtc ? msgs[0].enqueuedTimeUtc.valueOf() : 0;
@ -180,7 +180,7 @@ describe("Sender Tests", () => {
? [TestMessage.getSessionSample(), TestMessage.getSessionSample()]
: [TestMessage.getSample(), TestMessage.getSample()];
const scheduleTime = new Date(Date.now() + 10000); // 10 seconds from now
await sender.scheduleMessages(scheduleTime, testMessages);
await sender.scheduleMessages(testMessages, scheduleTime);
const msgs = await receiver.receiveMessages(2);
should.equal(Array.isArray(msgs), true, "`ReceivedMessages` is not an array");
@ -232,7 +232,7 @@ describe("Sender Tests", () => {
? TestMessage.getSessionSample()
: TestMessage.getSample();
const scheduleTime = new Date(Date.now() + 30000); // 30 seconds from now as anything less gives inconsistent results for cancelling
const [sequenceNumber] = await sender.scheduleMessages(scheduleTime, testMessage);
const [sequenceNumber] = await sender.scheduleMessages(testMessage, scheduleTime);
await delay(2000);
@ -249,10 +249,10 @@ describe("Sender Tests", () => {
: TestMessage.getSample;
const scheduleTime = new Date(Date.now() + 30000); // 30 seconds from now as anything less gives inconsistent results for cancelling
const [sequenceNumber1, sequenceNumber2] = await sender.scheduleMessages(scheduleTime, [
getTestMessage(),
getTestMessage()
]);
const [sequenceNumber1, sequenceNumber2] = await sender.scheduleMessages(
[getTestMessage(), getTestMessage()],
scheduleTime
);
await delay(2000);
@ -293,9 +293,9 @@ describe("Sender Tests", () => {
];
const [result1, result2, result3] = await Promise.all([
// Schedule messages in parallel
sender.scheduleMessages(date, messages[0]),
sender.scheduleMessages(date, messages[1]),
sender.scheduleMessages(date, messages[2])
sender.scheduleMessages(messages[0], date),
sender.scheduleMessages(messages[1], date),
sender.scheduleMessages(messages[2], date)
]);
const sequenceNumbers = [result1[0], result2[0], result3[0]];
compareSequenceNumbers(sequenceNumbers[0], sequenceNumbers[1]);
@ -354,7 +354,7 @@ describe("Sender Tests", () => {
const controller = new AbortController();
setTimeout(() => controller.abort(), 1);
try {
await sender.scheduleMessages(new Date(), [TestMessage.getSample()], {
await sender.scheduleMessages([TestMessage.getSample()], new Date(), {
abortSignal: controller.signal
});
throw new Error(`Test failure`);
@ -521,7 +521,7 @@ describe("ServiceBusMessage validations", function(): void {
it("ScheduleMessages() throws if " + testInput.title, async function(): Promise<void> {
let actualErrorMsg = "";
let actualErr;
await sender.scheduleMessages(new Date(), testInput.message).catch((err) => {
await sender.scheduleMessages(testInput.message, new Date()).catch((err) => {
actualErr = err;
actualErrorMsg = err.message;
});

Просмотреть файл

@ -511,7 +511,7 @@ describe("Errors after close()", function(): void {
should.equal(errorSendBatch, expectedErrorMsg, "Expected error not thrown for sendBatch()");
let errorScheduleMsgs: string = "";
await sender.scheduleMessages(new Date(Date.now() + 30000), [testMessage]).catch((err) => {
await sender.scheduleMessages([testMessage], new Date(Date.now() + 30000)).catch((err) => {
errorScheduleMsgs = err.message;
});
should.equal(