You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PLG Works Queue helps with managing subscription and publish critical events using EventEmitter and RabbitMQ. All events get published using node EventEmitter and, if configured, events are also published through RabbitMQ, using topic-based exchange.
5
+
PLG Works Queue helps with managing subscription and publish critical events using RabbitMQ. All events are published through RabbitMQ, using topic-based exchange.
6
6
7
-
## Install
7
+
## Prerequisites
8
+
- Basic understanding of RabbitMQ - [reference](https://www.rabbitmq.com/tutorials/amqp-concepts.html)
9
+
10
+
## Installation
8
11
9
12
```bash
10
13
npm install @plgworks/queue --save
11
14
```
12
15
13
16
## Initialize
14
-
While using this package initialize an instance of queue manager to use to publish an event or subscribe to an event(s). To initialize an instance RabbitMQ configuration is required. Using this instance various functional methods can be invoked. The configuration should include following parameters:
15
-
- <b>username</b> [string] (mandatory)
16
-
- <b>password</b> [string] (mandatory)
17
-
- <b>host</b> [string] (mandatory)
18
-
- <b>port</b> [string] (mandatory)
19
-
- <b>heartbeats</b> [string] (mandatory) heartbeats defines after what period of time the peer TCP connection should be considered unreachable.
20
-
- <b>clusterNodes</b> [Array] (mandatory) - List of RMQ hosts.
17
+
RabbitMQ configuration is needed in initialization of the package. The configuration should include following parameters:
- <b>heartbeats</b> [string] (mandatory) [heartbeats](https://www.rabbitmq.com/heartbeats.html) defines after what period of time the peer TCP connection should be considered unreachable.
23
+
- <b>clusterNodes</b> [Array] (mandatory) - List of [RMQ cluster](https://www.rabbitmq.com/clustering.html#node-names) hosts.
21
24
- <b>enableRabbitmq</b> [integer] (optional) 0 if local usage.
22
25
- <b>switchHostAfterSec</b> [integer] (optional) Wait time before switching RMQ host.
23
26
- <b>connectionTimeoutSec</b> [integer] (optional) Wait time for connection to establish.
24
27
25
-
Example snippet to initialize PLG Works queue manager.
26
-
28
+
Following snippet initializes PLG Works Queue Manager:
<br>Description: Subscribe to multiple topics over a queue.
52
+
<br>Parameters:
49
53
- <b>topics</b> [Array] (mandatory) - List of events to subscribe to.
50
-
- <b>options</b> [object] (mandatory) -
54
+
- <b>options</b> [object] (mandatory) Object with following keys:
51
55
- <b>queue</b> [string] (optional) - Name of the queue on which you want to receive all your subscribed events. These queues and events, published in them, have TTL of 6 days. If a queue name is not passed, a queue with a unique name is created and is deleted when the subscriber gets disconnected.
52
56
- <b>ackRequired</b> [integer] (optional) - The delivered message needs ack if passed 1 ( default 0 ). if 1 passed and ack not done, message will redeliver.
53
57
- <b>broadcastSubscription</b> [integer] (optional) - Set to 1, when queue needs to be subscribed to broadcasting events.
54
58
- <b>prefetch</b> [integer] (optional) - The number of messages released from queue in parallel. In case of ackRequired=1, queue will pause unless delivered messages are acknowledged.
55
59
- <b>readCallback</b> [function] (mandatory) - Callback method will be invoked whenever there is a new notification.
56
60
- <b>subscribeCallback</b> [function] (optional) - Callback method to return consumerTag.
- We also support pause and start queue consumption. According to your logical condition, you can fire below events from your process to cancel or restart consumption respectively.
0 commit comments