-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublisher.js
More file actions
94 lines (73 loc) · 1.96 KB
/
publisher.js
File metadata and controls
94 lines (73 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const stompit = require('stompit')
async function main() {
const connectOptions = {
'host': 'localhost',
'port': 61613,
'connectHeaders': {
'host': '/',
'login': 'admin',
'passcode': 'admin',
'heart-beat': '5000,5000'
}
}
stompit.connect(connectOptions, function (error, client) {
if (error) {
console.log('connect error ' + error.message)
return
}
for (let i = 0; i < 2000; i++) {
const sendHeaders = {
'destination': '/queue/test1',
'content-type': 'text/plain',
'JMSXGroupID':'t1',
/**
* In order to reset, 'JMSXGroupSeq':-1. So if another message is sent in the future with the same message group ID it will be reassigned to a new consumer.
* @see https://activemq.apache.org/message-groups
*/
// 'JMSXGroupSeq':-1
}
const frame = client.send(sendHeaders)
frame.write('t1 hello'+i.toString())
frame.end()
}
for (let i = 2000; i < 5000; i++) {
const sendHeaders = {
'destination': '/queue/test1',
'content-type': 'text/plain',
'JMSXGroupID':'t2'
}
const frame = client.send(sendHeaders)
frame.write('t2 hello'+i.toString())
frame.end()
}
client.disconnect()
// const subscribeHeaders = {
// 'destination': '/queue/test1',
// 'ack': 'client-individual',
// }
//
// client.subscribe(subscribeHeaders, function (error, message) {
//
// if (error) {
// console.log('subscribe error ' + error.message)
// return
// }
//
// message.readString('utf-8', function (error, body) {
//
// if (error) {
// console.log('read message error ' + error.message)
// return
// }
//
// console.log('received message: ' + body)
//
// client.ack(message)
//
// // client.disconnect()
// })
//
// })
})
}
main()