noodlefrenzy / node-amqp10

amqp10 is a promise-based, AMQP 1.0 compliant node.js client
MIT License
134 stars 56 forks source link

Unable to specify `closed=false` when sending Link @detach frame #249

Closed dnwe closed 8 years ago

dnwe commented 8 years ago

Currently the internal Link detach operation has a hard-coded value of closed=true

Link.prototype._sendDetach = function() {
  var detachFrame = new frames.DetachFrame({
    handle: this.handle,
    channel: this.session.channel,
    closed: true
  });

  this.session.connection.sendFrame(detachFrame);
};

Ideally it would be possible to override this as a parameter to the public Link.prototype.detach function. The use case for this is on a receiver Link where it may be used to indicate whether a durable subscription with remaining ttl should continue to store messages at the remote end (ready for delivery at re-attachment) or whether it should be deleted.

mbroadst commented 8 years ago

@dnwe agreed. In fact the definition of the performative indicates an additional error field which we should support from the public API:

<type name="detach" class="composite" source="list" provides="frame">
    <descriptor name="amqp:detach:list" code="0x00000000:0x00000016"/>
    <field name="handle" type="handle" mandatory="true"/>
    <field name="closed" type="boolean" default="false"/>
    <field name="error" type="error"/>
</type>

The error type should probably be required to be e.g. an errors.ProtocolError.