@raymanselltickets/common 1.0.17 → 1.0.19

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.
@@ -6,7 +6,7 @@ interface Event {
6
6
  }
7
7
  export declare abstract class Listener<T extends Event> {
8
8
  abstract subject: T['subject'];
9
- abstract onMessage(data: T['data'], msg: JsMsg): void;
9
+ abstract onMessage(data: T['data'], msg: JsMsg): Promise<void>;
10
10
  private jsManager;
11
11
  private jsClient;
12
12
  protected ackWait: number;
@@ -23,13 +23,14 @@ export class Listener {
23
23
  const consumer = await this.jsClient.consumers.get(stream, consumerInfo.name);
24
24
  while (true) {
25
25
  console.log(`[${consumerInfo.name}] Waiting for ${this.subject} messages...`);
26
- const messages = await consumer.consume({ max_messages: 1 });
26
+ const messages = await consumer.consume();
27
27
  try {
28
28
  for await (const msg of messages) {
29
29
  console.log(`Message received: ${this.subject} / ${stream}`);
30
30
  console.log(msg.seq, msg.string());
31
31
  const parsedData = msg.json();
32
- this.onMessage(parsedData, msg); // msg is ack'd in this handler
32
+ // we're awaiting since the iterator for processing messages will not yield a new message until the body of the loop completes
33
+ await this.onMessage(parsedData, msg); // msg is ack'd in this handler
33
34
  }
34
35
  }
35
36
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raymanselltickets/common",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",