Skip to content

Commit

Permalink
accept session (create receiver) after messages are all sent
Browse files Browse the repository at this point in the history
to avoid session lock expires error
  • Loading branch information
jeremymeng committed Nov 9, 2024
1 parent 33557e0 commit 67e164a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions sdk/servicebus/service-bus/test/internal/deleteMessages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ describe("Batch Receiver - batch delete messages", function (): void {
const sender2 = serviceBusClient.test.addToCleanup(
serviceBusClient.createSender(names.queue ?? names.topic!),
);
const receiver2 = await serviceBusClient.test.createReceiveAndDeleteReceiver({
...names,
sessionId: randomSessionId,
});

const numMessages = 3;
const toSend = [];
Expand All @@ -165,6 +161,10 @@ describe("Batch Receiver - batch delete messages", function (): void {
}
await sender2.sendMessages(toSend);

const receiver2 = await serviceBusClient.test.createReceiveAndDeleteReceiver({
...names,
sessionId: randomSessionId,
});
const peeked = await receiver2.peekMessages(numMessages + 10);
assert.equal(peeked.length, numMessages);

Expand All @@ -181,10 +181,6 @@ describe("Batch Receiver - batch delete messages", function (): void {
const sender2 = serviceBusClient.test.addToCleanup(
serviceBusClient.createSender(names.queue ?? names.topic!),
);
const receiver2 = await serviceBusClient.test.createReceiveAndDeleteReceiver({
...names,
sessionId: randomSessionId,
});

const numMessages = 5000;
let i = 0;
Expand All @@ -210,6 +206,10 @@ describe("Batch Receiver - batch delete messages", function (): void {

// wait for things to be ready
await delay(10 * 1000);
const receiver2 = await serviceBusClient.test.createReceiveAndDeleteReceiver({
...names,
sessionId: randomSessionId,
});
await receiver2.purgeMessages();

await testPeekMsgsLength(receiver2, 0);
Expand Down

0 comments on commit 67e164a

Please sign in to comment.