Not all test cases pass now. Recent commits break the test.
If a buffered queue is full, producers are now no longer throttled. SIQ creates a new instance of the queue in memory. When flushing, messages from all full instances of a queue are sent to each consumer
A simple websocket queueing service written in javascript
- Clone this repo
cdinto the directory and donpm install. Wait till dependencies are installednpm testwill run the testsnpm startwill run the SIQ server
Examples are in /examples directory
Queues flush messages to subscribers ONLY when queue is full. Default queue size is 5. This can be changed at serverConfig.development.json. The createQueue API provides method to create queues with custom length
All queues and messages are persisted to a sqlite database. Messages corresponding to a queue are deleted from the db when the queue flushes.
var Siq = require('../src/client/siq');
//change port as required. Siq.connect returns a javascript promise
var siqConnection = Siq.connect('ws://localhost:8888');
siqConnection.then((siq) => {
//access siq APIs
});
var Siq = require('../src/client/siq');
var siqConnection = Siq.connect('ws://localhost:8888');
siqConnection.then((siq) => {
var producer = siq.createProducer();
producer.produce('queueName', 'message', (id) => {
//id is a uuid generated by siq for the enqueued message
//
}, (error) => {
//calls this function with an error if message could not be enqueued
//Could happen if the queue is full
});
});
var Siq = require('../src/client/siq');
var siqConnection = Siq.connect('ws://localhost:8888');
siqConnection.then((siq) => {
var callback = function(messageList){
/*
Gets invoked when queue is full
messageList is an array of all messages that was in the queue
*/
};
/*consumerTest is the name of the queue*/
var consumerConnection = siq.createConsumer('consumerTest', callback);
});
If you want to create a queue with a buffer size different from that of the default one, use the createQueue API
var Siq = require('../src/client/siq');
var siqConnection = Siq.connect('ws://localhost:8888');
siqConnection.then((siq) => {
var bufferSize = 20;
siq.createQueue('customQueue', bufferSize, (name) => {
/*
If queue creation was successfull, name will contain the name of the queue. In this case, 'customQueue'
*/
});
});