Skip to content

Commit

Permalink
Merge pull request #550 from nats-io/fix-no-mux-payload
Browse files Browse the repository at this point in the history
[FIX] noMux option for request many elided request payload
  • Loading branch information
aricart committed Jun 26, 2023
2 parents 274868a + 4e53de6 commit 4a4844b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nats-base-client/nats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 The NATS Authors
* Copyright 2018-2023 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -279,7 +279,7 @@ export class NatsConnectionImpl implements NatsConnection {
});

try {
this.publish(subject, Empty, { reply: sub.getSubject() });
this.publish(subject, data, { reply: sub.getSubject() });
} catch (err) {
cancel(err);
}
Expand Down
7 changes: 6 additions & 1 deletion tests/mrequest_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@ async function requestManyCount(noMux = false): Promise<void> {
const { ns, nc } = await setup({});
const nci = nc as NatsConnectionImpl;

let payload = "";
const subj = createInbox();
nc.subscribe(subj, {
callback: (_err, msg) => {
if (payload === "") {
payload = msg.string();
}
for (let i = 0; i < 5; i++) {
msg.respond();
}
},
});

const iter = await nci.requestMany(subj, Empty, {
const iter = await nci.requestMany(subj, "hello", {
strategy: RequestStrategy.Count,
maxWait: 2000,
maxMessages: 5,
Expand All @@ -58,6 +62,7 @@ async function requestManyCount(noMux = false): Promise<void> {
}

assertEquals(nci.protocol.subscriptions.size(), noMux ? 1 : 2);
assertEquals(payload, "hello");
assertEquals(iter.getProcessed(), 5);
await cleanup(ns, nc);
}
Expand Down

0 comments on commit 4a4844b

Please sign in to comment.