Skip to content

Commit 514aa10

Browse files
l4mbymagne
and
magne
authored
fix: example beahviour (#467)
Co-authored-by: magne <[email protected]>
1 parent 5747b53 commit 514aa10

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

javascript-nodejs-stream/offset_tracking_receive.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const rabbit = require("rabbitmq-stream-js-client");
33
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
44

55
async function main() {
6-
const streamName = "stream-offset-tracking-javascript";
7-
86
console.log("Connecting...");
97
const client = await rabbit.connect({
108
hostname: "localhost",
@@ -14,6 +12,10 @@ async function main() {
1412
vhost: "/",
1513
});
1614

15+
console.log("Making sure the stream exists...");
16+
const streamName = "stream-offset-tracking-javascript";
17+
await client.createStream({ stream: streamName, arguments: {} });
18+
1719
const consumerRef = "offset-tracking-tutorial";
1820
let firstOffset = undefined;
1921
let offsetSpecification = rabbit.Offset.first();
@@ -47,13 +49,10 @@ async function main() {
4749
console.log(`Start consuming...`);
4850
await sleep(2000);
4951
console.log(`Done consuming, first offset was ${firstOffset}, last offset was ${lastOffset}`);
50-
process.exit(0);
5152
}
5253

5354
main()
54-
.then(async () => {
55-
await new Promise(function () {});
56-
})
55+
.then(async () => process.exit(0))
5756
.catch((res) => {
5857
console.log("Error while receiving message!", res);
5958
process.exit(-1);

javascript-nodejs-stream/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript-nodejs-stream/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"receive": "node receive.js"
1010
},
1111
"dependencies": {
12-
"rabbitmq-stream-js-client": "^0.4.1"
12+
"rabbitmq-stream-js-client": "^0.4.2"
1313
}
1414
}

0 commit comments

Comments
 (0)