Permalink
Browse files

cleaner and more manageable handling of server channel closes

  • Loading branch information...
1 parent 364e137 commit b471cc15f0273ba06e12dcf237452cb1cc44c031 @postwait committed Sep 19, 2011
Showing with 9 additions and 12 deletions.
  1. +2 −0 History.md
  2. +7 −12 amqp.js
View
@@ -3,6 +3,8 @@
* Change the default json content type to application/json
* add a basic-return event for exchanges to catch simple
basicReturn messages.
+ * cleaner and more manageable handling of server channel closes
+ from Glen Mailer.
0.1.0 / 2011-07-30
==================
View
19 amqp.js
@@ -1700,19 +1700,15 @@ Queue.prototype._onMethod = function (channel, method, args) {
case methods.channelClose:
this.state = "closed";
-/*
+ this.connection.queueClosed(this.name);
var e = new Error(args.replyText);
e.code = args.replyCode;
- if (!this.listeners('close').length) {
- sys.puts('Unhandled channel error: ' + args.replyText);
- }
this.emit('error', e);
-*/
this.emit('close');
break;
case methods.channelCloseOk:
- delete this.connection.queues[this.name]
+ this.connection.queueClosed(this.name);
this.emit('close')
break;
@@ -1801,17 +1797,16 @@ Exchange.prototype._onMethod = function (channel, method, args) {
case methods.channelClose:
this.state = "closed";
+ this.connection.exchangeClosed(this.name);
var e = new Error(args.replyText);
e.code = args.replyCode;
- if (!this.listeners('close').length) {
- sys.puts('Unhandled channel error: ' + args.replyText);
- }
- this.emit('close', e);
+ this.emit('error', e);
+ this.emit('close');
break;
case methods.channelCloseOk:
- delete this.connection.exchanges[this.name]
- this.emit('close')
+ this.connection.exchangeClosed(this.name);
+ this.emit('close');
break;
case methods.basicReturn:

0 comments on commit b471cc1

Please sign in to comment.