@@ -4,96 +4,19 @@ stomp-js
4
4
## Overview
5
5
6
6
An exercise with node.js to implement the STOMP protocol.
7
- The design & implementation is heavily inspired by [ python-stomp] ( http://bitbucket.org/benjaminws/python-stomp/ ) , with an evented twist.
8
7
9
- This is merely the first iteration; a complete spike. I will be rewriting it from the ground up with BDD.
8
+ For documentation see doc/stomp.md and doc/frame.md
10
9
11
10
## Examples
12
11
13
12
### Consumer
14
13
15
- #!/usr/bin/env node
16
-
17
- var stomp = require('./lib/stomp');
18
-
19
- var stomp_args = {
20
- port: 61613,
21
- host: 'localhost',
22
- debug: true
23
- }
24
- // Could also add..
25
- //{login: 'bah', password: 'bah'}
26
-
27
- var client = new stomp.Stomp(stomp_args);
28
-
29
- var headers = {
30
- destination: '/queue/test_stomp',
31
- ack: 'client'
32
- };
33
-
34
- var messages = [];
35
-
36
- client.connect();
37
-
38
- client.on('connected', function() {
39
- client.subscribe(headers);
40
- console.log('Connected');
41
- });
42
-
43
- client.on('message', function(message) {
44
- messages.push(message);
45
- });
46
-
47
- client.on('error', function(error_frame) {
48
- console.log(error_frame.body);
49
- });
50
-
51
- process.on('SIGINT', function() {
52
- console.log('\nConsumed ' + messages.length + ' messages');
53
- client.disconnect();
54
- });
14
+ See stomp-consumer.js
55
15
56
16
### Producer
57
17
58
- #!/usr/bin/env node
59
-
60
- var stomp = require('./lib/stomp');
61
-
62
- var num = process.argv[2];
63
-
64
- var stomp_args = {
65
- port: 61613,
66
- host: 'localhost',
67
- debug: true
68
- }
69
- // Could also add..
70
- //{login: 'bah', password: 'bah'}
71
-
72
- var client = new stomp.Stomp(stomp_args);
73
-
74
- var queue = '/queue/test_stomp';
75
-
76
- client.connect();
77
-
78
- client.on('connected', function() {
79
- if (!num) num = 10;
80
-
81
- for (var i = 0; i < num; i++) {
82
- console.log(i);
83
- client.send({
84
- 'destination': queue,
85
- 'body': 'Testing' + i,
86
- 'persistent': 'true'
87
- });
88
- }
89
- client.disconnect();
90
- });
18
+ See stomp-producer.js
91
19
92
- client.on('error', function(error_frame) {
93
- console.log(error_frame.body);
94
- client.disconnect();
95
- });
20
+ ### Producer with Transaction Support
96
21
97
- process.on('SIGINT', function() {
98
- client.disconnect();
99
- });
22
+ See stomp-producer-txn.js
0 commit comments