Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add posibility to attach ReceiverLink delayed in code & createReceiverLink promise will resolve immediatelly #311

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a name="3.5.1"></a>
## [3.5.1](https://github.com/noodlefrenzy/node-amqp10/compare/v3.5.0...v3.5.1) (2017-03-14)



<a name="3.5.0"></a>
# [3.5.0](https://github.com/noodlefrenzy/node-amqp10/compare/v3.4.2...v3.5.0) (2017-03-07)

Expand Down
6 changes: 5 additions & 1 deletion lib/amqp_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ AMQPClient.prototype.createReceiver = function(address, policyOverrides) {
};

var link = self._session.createLink(linkPolicy);
link._onAttach.push(attachPromise);
if (!linkPolicy.attach.manually) {
link._onAttach.push(attachPromise);
} else {
attachPromise(null, link);
}
};

attach();
Expand Down
4 changes: 3 additions & 1 deletion lib/policies/policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function Policy(overrides) {
* @property {number|string} attach.receiverSettleMode The delivery settlement policy for the receiver
* @property {number} attach.maxMessageSize The maximum message size supported by the link endpoint
* @property {number} attach.initialDeliveryCount This must not be null if role is sender, and it is ignored if the role is receiver.
* @property {number} attach.manually To invoke attach self in your code set this option to true
* @property {function} credit A function that determines when (if ever) to refresh the receiver link's credit
* @property {number} creditQuantum Quantum used in pre-defined credit policy functions
* @property {function|null} decoder=null The optional decoder used for all incoming data
Expand All @@ -170,7 +171,8 @@ function Policy(overrides) {
role: constants.linkRole.receiver,
receiverSettleMode: constants.receiverSettleMode.autoSettle,
maxMessageSize: 10000, // Arbitrary choice
initialDeliveryCount: 1
initialDeliveryCount: 1,
manually: false
},
credit: putils.CreditPolicies.RefreshAtHalf,
creditQuantum: 100,
Expand Down
8 changes: 5 additions & 3 deletions lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,11 @@ Session.prototype.createLink = function(linkPolicy) {
self.emit(Session.ErrorReceived, err);
});

if (this.mapped) {
// immediately attempt to attach link
link.attach();
if (!policy.attach.manually) {
if (this.mapped) {
// immediately attempt to attach link
link.attach();
}
}

return link;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amqp10",
"version": "3.5.0",
"version": "3.5.1",
"description": "Native AMQP-1.0 client for node.js",
"main": "./lib",
"engines": {
Expand All @@ -18,8 +18,8 @@
"devDependencies": {
"benchmark": "^2.1.2",
"chai": "^3.5.0",
"chai-string": "^1.3.0",
"chai-as-promised": "^6.0.0",
"chai-string": "^1.3.0",
"conventional-changelog-cli": "^1.2.0",
"gh-pages": "^0.12.0",
"istanbul": "^0.4.5",
Expand Down