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
Copy file name to clipboardExpand all lines: readme.md
+68-29Lines changed: 68 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,15 @@ NPM package is published as updated-node-msmq. https://www.npmjs.com/package/upd
10
10
11
11
* Support for Node.Js 6.x, 7.x, 8.x, 9.x, 10.x
12
12
* Support to push objects to the queue instead of just strings.
13
-
* Support to send messages to a queue on a **remote** machine.
13
+
* Support to send/receive messages to/from a queue on a **remote** machine.
14
14
15
15
## Install
16
16
17
17
```
18
18
$ npm install --save updated-node-msmq
19
19
```
20
20
21
-
## Usage
21
+
## Usage (Local Queue)
22
22
23
23
### Send a message
24
24
@@ -33,6 +33,48 @@ var queue = msmq.openOrCreateQueue('.\\Private$\\MyAwesomeQueue');
33
33
queue.send('Hello from Node.JS!');
34
34
```
35
35
36
+
### Receive messages
37
+
38
+
Start receiving messages from a queue.
39
+
40
+
```js
41
+
constmsmq=require('updated-node-msmq');
42
+
43
+
var queue =msmq.openOrCreateQueue('.\\Private$\\MyAwesomeQueue');
44
+
45
+
// Set receive listener callback
46
+
queue.on('receive', (msg) => {
47
+
console.log(msg.body);
48
+
});
49
+
50
+
// Start receiving messages from the queue
51
+
queue.startReceiving();
52
+
```
53
+
54
+
### Get all messages
55
+
56
+
Gets all messages without removing them from queue.
57
+
58
+
```js
59
+
constmsmq=require('updated-node-msmq');
60
+
61
+
var queue =msmq.openOrCreateQueue('.\\Private$\\MyAwesomeQueue');
62
+
var messages =queue.getAllMessages();
63
+
```
64
+
65
+
### Purge a queue
66
+
67
+
Clears all messages from the queue.
68
+
69
+
```js
70
+
constmsmq=require('updated-node-msmq');
71
+
72
+
var queue =msmq.openOrCreateQueue('.\\Private$\\MyAwesomeQueue');
73
+
queue.purge();
74
+
```
75
+
76
+
## Usage (Remote Queue)
77
+
36
78
### Send a message to a remote queue
37
79
38
80
Sends a message to a remote MSMQ queue.
@@ -41,35 +83,26 @@ Sends a message to a remote MSMQ queue.
41
83
constmsmq=require('updated-node-msmq');
42
84
43
85
// Send message to a remote queue using hostname
44
-
msmq.sendToRemoteQueue('FormatName:DIRECT=OS:mobile-000000\\private$\\privatetest', 'Hello from Node.JS!');
86
+
let queue1 =msmq.connectToRemoteQueue('FormatName:DIRECT=OS:mobile-000000\\private$\\privatetest');
45
87
46
-
msmq.sendToRemoteQueue('FormatName:DIRECT=TCP:192.168.1.5\\private$\\privatetest', 'Hello again from Node.JS!');
47
-
```
88
+
queue1.send('Hello again from Node.JS!');
48
89
49
-
#### Note:
50
-
* Creating a queue on a remote machine is not currently supported by MSMQ.
51
-
* To send messages to a remote queue, MSMQ should be enabled in the sender's machine too. Also, in the _Security_ tab of the queue on the remote machine should have the appropriate permissions set for _Everyone_ and _ANONYMOUS LOGON_.
52
-
* The queue should already be created on the remote machine.
53
-
* The format to send a message to a remote queue is as follows:
54
-
`
55
-
msmsq.sendToRemoteQueue(path, message);
56
-
`
57
-
*`path` has to be in the following format:
90
+
// Send message to a remote queue using IP address
91
+
let queue2 =msmq.connectToRemoteQueue('FormatName:DIRECT=TCP:192.168.5.21\\private$\\privatetest');
var queue =msmq.openOrCreateQueue('.\\Private$\\MyAwesomeQueue');
105
+
var queue =msmq.connectToRemoteQueue('FormatName:DIRECT=OS:mobile-000000\\private$\\privatetest');
73
106
74
107
// Set receive listener callback
75
108
queue.on('receive', (msg) => {
@@ -82,25 +115,31 @@ queue.startReceiving();
82
115
83
116
### Get all messages
84
117
85
-
Gets all messages without removing them from queue.
118
+
Gets all messages without removing them from a remote queue.
86
119
87
120
```js
88
121
constmsmq=require('updated-node-msmq');
89
122
90
-
var queue =msmq.openOrCreateQueue('.\\Private$\\MyAwesomeQueue');
123
+
var queue =msmq.connectToRemoteQueue('.\\Private$\\MyAwesomeQueue');
91
124
var messages =queue.getAllMessages();
92
125
```
93
126
94
-
### Purge a queue
127
+
#### Note:
128
+
* Creating a queue / Checking if a queue exists on a remote machine is currently not supported by MSMQ.
129
+
* To communicate with a remote queue, MSMQ should be enabled in the sender's machine too. Also, in the _Security_ tab of the queue on the remote machine should have the appropriate permissions set for _Everyone_ and _ANONYMOUS LOGON_.
130
+
* The queue should already be created on the remote machine.
131
+
* The format to connect to a remote queue is as follows:
0 commit comments