geonix 1.22.5 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Service.js +4 -2
- package/test/pubsub.js +29 -0
package/package.json
CHANGED
package/src/Service.js
CHANGED
|
@@ -226,8 +226,10 @@ export class Service {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
async #sub(
|
|
230
|
-
const
|
|
229
|
+
async #sub(_subject, handler) {
|
|
230
|
+
const [subject, queue] = _subject.split(",");
|
|
231
|
+
|
|
232
|
+
const subscription = await connection.subscribe(subject, { queue });
|
|
231
233
|
const processor = async () => {
|
|
232
234
|
for await (const event of subscription) {
|
|
233
235
|
handler(event.data);
|
package/test/pubsub.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Publish, Remote, Service } from "../exports.js";
|
|
2
|
+
import { sleep } from "../src/Util.js";
|
|
3
|
+
|
|
4
|
+
class TimeService extends Service {
|
|
5
|
+
|
|
6
|
+
counter = 0;
|
|
7
|
+
|
|
8
|
+
"SUB test,q1"(data) {
|
|
9
|
+
console.log(`SUB test (${this.counter++})`, data);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class ApplicationService extends Service {
|
|
15
|
+
|
|
16
|
+
async onStart() {
|
|
17
|
+
await sleep(1000);
|
|
18
|
+
|
|
19
|
+
while (true) {
|
|
20
|
+
await Publish("test", "Hello World");
|
|
21
|
+
await sleep(1000);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
TimeService.start();
|
|
28
|
+
TimeService.start();
|
|
29
|
+
ApplicationService.start();
|