{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/amqpnetlite/issues/56","labels_url":"https://api.github.com/repos/Azure/amqpnetlite/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/Azure/amqpnetlite/issues/56/comments","events_url":"https://api.github.com/repos/Azure/amqpnetlite/issues/56/events","html_url":"https://github.com/Azure/amqpnetlite/issues/56","id":121606501,"number":56,"title":"Flow control drain flag","user":{"login":"robreeves","id":5604993,"avatar_url":"https://avatars.githubusercontent.com/u/5604993?v=3","gravatar_id":"","url":"https://api.github.com/users/robreeves","html_url":"https://github.com/robreeves","followers_url":"https://api.github.com/users/robreeves/followers","following_url":"https://api.github.com/users/robreeves/following{/other_user}","gists_url":"https://api.github.com/users/robreeves/gists{/gist_id}","starred_url":"https://api.github.com/users/robreeves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robreeves/subscriptions","organizations_url":"https://api.github.com/users/robreeves/orgs","repos_url":"https://api.github.com/users/robreeves/repos","events_url":"https://api.github.com/users/robreeves/events{/privacy}","received_events_url":"https://api.github.com/users/robreeves/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-11T00:07:12Z","updated_at":"2015-12-23T18:41:46Z","closed_at":null,"body":"I am trying to understand the drain flag described in 2.6.7 Flow Control of the AMQP 1.0 spec. \r\n\r\nhttp://docs.oasis-open.org/amqp/core/v1.0/cos01/amqp-core-transport-v1.0-cos01.html#doc-flow-control\r\n\r\nFrom what I understand if the drain flag is true and the sender link does not have any messages to send it should basically “return” the credit by consuming the credit and sending the flow state to the receiver link. I am not seeing that behavior with SenderLink and I’m not sure if my understanding of the drain flag is incomplete or if this is a possible bug. \r\n\r\nIn SenderLink.OnFlow I see nowhere that the Flow.Drain property is honored. I see no place in the entire Amqp.Net project where the Flow.Drain property is used besides being set actually. Instead if SenderLink.OnFlow has no outgoing messages it just returns and keeps the credit. Is this a bug? \r\n\r\nHere is a sample application where I updated the sender link’s credit with drain set to true and the sender keeps the credit. \r\n\r\n    class Program\r\n    {\r\n        const string Address = \"amqp://localhost:5462\";\r\n        const string MsgQueue = \"queue\";\r\n\r\n        static void Main(string[] args)\r\n        {\r\n            var host = new ContainerHost(new Uri(Address));\r\n            host.RegisterMessageProcessor(MsgQueue, new MessageProcessor());\r\n            host.Open();\r\n\r\n            var conn = new Connection(new Address(Address));\r\n            var sess = new Session(conn);\r\n            var sender = new SenderLink(sess, \"client\", MsgQueue);\r\n\r\n            sender.Send(new Message(\"1\"));\r\n\r\n            //Shouldn't sender.credit be 0 here?\r\n        }\r\n    }\r\n\r\n    class MessageProcessor : IMessageProcessor\r\n    {\r\n\r\n        public int Credit\r\n        {\r\n            get { return 1; }\r\n        }\r\n\r\n        public void Process(MessageContext messageContext)\r\n        {\r\n            Console.WriteLine(messageContext.Message.Body);\r\n            messageContext.Link.SetCredit(10, true);\r\n            messageContext.Complete();\r\n        }\r\n    }\r\n"},"comment":{"url":"https://api.github.com/repos/Azure/amqpnetlite/issues/comments/166967661","html_url":"https://github.com/Azure/amqpnetlite/issues/56#issuecomment-166967661","issue_url":"https://api.github.com/repos/Azure/amqpnetlite/issues/56","id":166967661,"user":{"login":"robreeves","id":5604993,"avatar_url":"https://avatars.githubusercontent.com/u/5604993?v=3","gravatar_id":"","url":"https://api.github.com/users/robreeves","html_url":"https://github.com/robreeves","followers_url":"https://api.github.com/users/robreeves/followers","following_url":"https://api.github.com/users/robreeves/following{/other_user}","gists_url":"https://api.github.com/users/robreeves/gists{/gist_id}","starred_url":"https://api.github.com/users/robreeves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robreeves/subscriptions","organizations_url":"https://api.github.com/users/robreeves/orgs","repos_url":"https://api.github.com/users/robreeves/repos","events_url":"https://api.github.com/users/robreeves/events{/privacy}","received_events_url":"https://api.github.com/users/robreeves/received_events","type":"User","site_admin":false},"created_at":"2015-12-23T18:41:46Z","updated_at":"2015-12-23T18:41:46Z","body":"@xinchen10 Thanks for the explanation. I don't have a tangible use case to implement the drain flag right now. Just exploring my options and making sure I understand the things properly. \r\n\r\nRegardless of the drain flag the first paradigm you described sounds interesting - A sender link with no credit requesting credits when it has a message to send. I don't see access to the flow methods in SenderLink or Link. Is there a way to do this in the library on the client side? I know I could control the flow on the broker side using an ILinkProcessor."}}