From 5fdde6587390b6755a90d70f1032ff8cc128eb93 Mon Sep 17 00:00:00 2001 From: Michael Freund Date: Mon, 5 May 2014 11:39:11 +0200 Subject: [PATCH 1/6] implemented NACK --- lib/stomp.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/stomp.js b/lib/stomp.js index bb51546..34faa4a 100644 --- a/lib/stomp.js +++ b/lib/stomp.js @@ -399,6 +399,19 @@ Stomp.prototype.ack = function(message_id) { this.log.debug('acknowledged message: ' + message_id); }; + +// +// ## Stomp.nack(message_id) +// +// **Deny received message** +// +// Takes a string representing the message id to nack +// +Stomp.prototype.nack = function(message_id) { + send_command(this, 'NACK', {'message-id': message_id}); + this.log.debug('denied message: ' + message_id); +}; + // // ## Stomp.begin() // From e7af1744c12cec784251dfdc33a953d6705fb959 Mon Sep 17 00:00:00 2001 From: Alban Mouton Date: Fri, 1 Aug 2014 22:45:22 +0200 Subject: [PATCH 2/6] The matching subscribed queue will be found in the subscription headers in the case of a reply-to temp queue with rabbitmq --- lib/stomp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stomp.js b/lib/stomp.js index bb51546..1cd91cb 100644 --- a/lib/stomp.js +++ b/lib/stomp.js @@ -294,7 +294,8 @@ Stomp.prototype.is_a_message = function(this_frame) { // Takes a `Frame` object // Stomp.prototype.should_run_message_callback = function(this_frame) { - var subscription = this._subscribed_to[this_frame.headers.destination]; + // The matching subscribed queue will be found in the subscription headers in the case of a reply-to temp queue with rabbitmq + var subscription = this._subscribed_to[this_frame.headers.destination] || this._subscribed_to[this_frame.headers.subscription]; if (this_frame.headers.destination !== null && subscription !== null) { if (subscription.enabled && subscription.callback !== null && typeof(subscription.callback) == 'function') { subscription.callback(this_frame.body, this_frame.headers); From d8d7527a1afb7a8cb55aa02d6701d9005154a367 Mon Sep 17 00:00:00 2001 From: Alban Mouton Date: Fri, 1 Aug 2014 22:52:39 +0200 Subject: [PATCH 3/6] add nack support copied from xFragger/stomp-js --- lib/stomp.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/stomp.js b/lib/stomp.js index 1cd91cb..e7ebb36 100644 --- a/lib/stomp.js +++ b/lib/stomp.js @@ -400,6 +400,18 @@ Stomp.prototype.ack = function(message_id) { this.log.debug('acknowledged message: ' + message_id); }; +// +// ## Stomp.nack(message_id) +// +// **Deny received message** +// +// Takes a string representing the message id to nack +// +Stomp.prototype.nack = function(message_id) { + send_command(this, 'NACK', {'message-id': message_id}); + this.log.debug('denied message: ' + message_id); +}; + // // ## Stomp.begin() // From e3e5f8d78915d2281036a6dd0ec259e9fb82c281 Mon Sep 17 00:00:00 2001 From: marcingasior Date: Sun, 12 Oct 2014 22:31:39 +0100 Subject: [PATCH 4/6] Add keep alive to socket This one prevents closing sockets by external service. It happens that after 2 minutes socket is closed by remote, and there is no event connected to it. I expected to get timeout event, but it is never happened in my case. --- lib/stomp.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/stomp.js b/lib/stomp.js index bb51546..acf7db2 100644 --- a/lib/stomp.js +++ b/lib/stomp.js @@ -137,6 +137,8 @@ function _setupListeners(stomp) { var socket = stomp.socket; + socket.setKeepAlive(true); + socket.on('drain', function(data) { log.debug('draining'); }); From 21bbfde149463478224bb2ad773cc0b25121c653 Mon Sep 17 00:00:00 2001 From: Nick Sellen Date: Thu, 16 Apr 2015 11:14:47 +0200 Subject: [PATCH 5/6] fix check for missing subscription --- lib/stomp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stomp.js b/lib/stomp.js index bb51546..04577d9 100644 --- a/lib/stomp.js +++ b/lib/stomp.js @@ -295,7 +295,7 @@ Stomp.prototype.is_a_message = function(this_frame) { // Stomp.prototype.should_run_message_callback = function(this_frame) { var subscription = this._subscribed_to[this_frame.headers.destination]; - if (this_frame.headers.destination !== null && subscription !== null) { + if (this_frame.headers.destination !== null && subscription) { if (subscription.enabled && subscription.callback !== null && typeof(subscription.callback) == 'function') { subscription.callback(this_frame.body, this_frame.headers); } From 72af21c2f424b297164bc35eefb733762c187ae3 Mon Sep 17 00:00:00 2001 From: Nenu Adrian Date: Tue, 24 Nov 2015 14:43:10 +0000 Subject: [PATCH 6/6] If the length of the header array is 1 or 0 then it makes no sense to try to access index 1, I had it crash on me, but worked well with this removal of code which seems quite ilogical to have there, legacy? --- lib/stomp.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/stomp.js b/lib/stomp.js index a5fcb33..d27301d 100644 --- a/lib/stomp.js +++ b/lib/stomp.js @@ -51,7 +51,6 @@ function parse_headers(raw_headers) { headers[header_key] = header_val; continue; } - headers[header[0].trim()] = header[1].trim(); } return headers; };