Created
January 19, 2011 16:15
-
-
Save benjaminws/786378 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var stomp = require('stomp'); | |
var num = process.argv[2]; | |
// Set to true if you want a receipt | |
// of all messages sent. | |
var receipt = false; | |
// Set debug to true for more verbose output. | |
// login and passcode are optional (required by rabbitMQ) | |
var stomp_args = { | |
port: 61613, | |
host: 'localhost', | |
debug: false, | |
login: 'guest', | |
passcode: 'guest', | |
} | |
var client = new stomp.Stomp(stomp_args); | |
var queue = '/queue/test_stomp'; | |
client.connect(); | |
client.on('connected', function() { | |
num = num || 1000; | |
for (var i = 0; i < num; i++) { | |
client.send({ | |
'destination': queue, | |
'body': 'Testing' + i, | |
'persistent': 'true' | |
}, receipt); | |
} | |
console.log('Produced ' + num + ' messages'); | |
client.disconnect(); | |
}); | |
client.on('receipt', function(receipt) { | |
console.log("RECEIPT: " + receipt); | |
}); | |
client.on('error', function(error_frame) { | |
console.log(error_frame.body); | |
client.disconnect(); | |
}); | |
process.on('SIGINT', function() { | |
console.log('Produced ' + num + ' messages'); | |
client.disconnect(); | |
process.exit(0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment