From celldee at gmail.com Sat Jan 9 05:38:36 2010 From: celldee at gmail.com (Chris Duncan) Date: Sat, 9 Jan 2010 10:38:36 +0000 Subject: [bunny-amqp-devel] Handling AMQP Channel.Flow methods in Bunny Message-ID: Hi, I need to canvass opinion. As you may or may not know, I've tried to make Bunny easy to use. There is always room for improvement, and one of the things that needs addressing is handling of AMQP Channel.Flow methods. The Channel.Flow method allows an AMQP server that is low on resources to tell a message publishing AMQP client to stop publishing messages in order to prevent a crash. So if you haven't been operating at the ragged edge of server performance then you probably haven't had to deal with Channel.Flow. The AMQP Basic.Publish method that Bunny uses to publish messages is asynchronous in AMQP terms. That means that it doesn't return a confirmation of success. Therefore, in Bunny I have a problem checking the success of a publish because the only way I know that publish has worked, without making other calls, is by the absence of error conditions. What I would like to do to handle Channel.Flow is something like - 1. Make a publish call 2. Check the return value (if specified in the publish call) 3. Take appropriate action Nope, can't do number 2 because there isn't anything to check. However, I could try to read from the socket after making the publish call to determine whether a Channel.Flow method has been sent from the server. There are problems with that approach too - 1. Bunny does a blocking read. If there is nothing to read, Bunny will wait indefinitely unless timeout.rb is used. My testing has alerted me to the possibility that timeout.rb cannot be relied upon in this scenario even in Ruby 1.9. 2. If I go with timeout.rb nonetheless, how long should the timeout period be? If the timeout period is too short I might miss a Channel.Flow message. Too long and it will slow down publishing to a degree that could prove unacceptable. 3. I could use select() with no blocking but that would mean some re- engineering in a fundamental part of the code. It is possible for me to catch the Channel.Flow methods as a consequence of other synchronous AMQP calls. I could implement this functionality very easily. So, I'm not going to do anything without consulting the people who use Bunny, namely yourselves. If I don't get any feedback on this then I will assume that it's not a major issue and ignore it. If you want something done about it then please let me know what behaviour you need, fork the project on GitHub and try out some solutions, whatever floats your boat. A couple of people have already addressed this topic with me and I thank them for their input. Regards, Chris From celldee at gmail.com Mon Jan 11 15:33:53 2010 From: celldee at gmail.com (Chris Duncan) Date: Mon, 11 Jan 2010 20:33:53 +0000 Subject: [bunny-amqp-devel] Another test message Message-ID: Just to see if the group is still working for me. From chris.d at frugalit.co.uk Mon Jan 11 16:13:35 2010 From: chris.d at frugalit.co.uk (Chris Duncan (Frugal IT)) Date: Mon, 11 Jan 2010 21:13:35 +0000 Subject: [bunny-amqp-devel] Test message from a new member Message-ID: <7FCAA5FA-471E-4367-90C6-42973E63E26D@frugalit.co.uk> Yet another test message. From pathsny at gmail.com Mon Jan 18 23:04:37 2010 From: pathsny at gmail.com (vishnu) Date: Tue, 19 Jan 2010 09:34:37 +0530 Subject: [bunny-amqp-devel] using bunny with rails to send messages Message-ID: Hi, I was wondering if anyone on the list uses bunny with rails. Is there anything people do to keep the connection persistent across requests? By moving this code into the rails startup maybe? Also has anyone tried sharing the connection across multiple rails processes (does that even make sense?), or pooling the connections? thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From westling at perceptech.com Mon Jan 18 23:23:24 2010 From: westling at perceptech.com (Mark Westling) Date: Mon, 18 Jan 2010 23:23:24 -0500 Subject: [bunny-amqp-devel] using bunny with rails to send messages In-Reply-To: References: Message-ID: <3de9aeb51001182023q177d5daer3c9216472be9ef9b@mail.gmail.com> I'm using Bunny inside a Rails 2.3 application that runs on Passenger. I keep the connection in thread-local variables, like this: begin b = (Thread.current[:bunny] ||= Bunny.new(:host => AMQ_HOST)) b.start unless b.status == :connected q = (Thread.current[queue] ||= b.queue(QUEUE_NAME)) q.publish(message) rescue Exception => e Thread.current[:bunny] = nil # Force a reconnection retry if (retries -= 1) >= 0 end The first time this section of code runs it opens the connection and stores it for reuse. The thread-local variables prevent multiple threads from running into each other. This approach is working fine (but I'm open to suggestions!). --Mark On Mon, Jan 18, 2010 at 11:04 PM, vishnu wrote: > Hi, > I was wondering if anyone on the list uses bunny with rails. Is there > anything people do to keep the connection persistent across requests? By > moving this code into the rails startup maybe? > > Also has anyone tried sharing the connection across multiple rails > processes (does that even make sense?), or pooling the connections? > thanks > > _______________________________________________ > bunny-amqp-devel mailing list > bunny-amqp-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/bunny-amqp-devel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From celldee at gmail.com Tue Jan 19 01:28:09 2010 From: celldee at gmail.com (Chris Duncan) Date: Tue, 19 Jan 2010 06:28:09 +0000 Subject: [bunny-amqp-devel] Trouble with the Google Group Message-ID: <641DF969-26A3-4215-ACE0-8448B4193CA3@gmail.com> Hi, If anyone has been having trouble accessing the Bunny Google Group, please make sure that you join the Rubyforge mailing list (http:// rubyforge.org/mailman/listinfo/bunny-amqp-devel as well. The Google Group is just a convenience to allow access to the mailing list via a different interface. I will add a note to the Group description about this. Regards, Chris From pathsny at gmail.com Wed Jan 20 10:55:26 2010 From: pathsny at gmail.com (vishnu) Date: Wed, 20 Jan 2010 21:25:26 +0530 Subject: [bunny-amqp-devel] using bunny with rails to send messages In-Reply-To: <3de9aeb51001182023q177d5daer3c9216472be9ef9b@mail.gmail.com> References: <3de9aeb51001182023q177d5daer3c9216472be9ef9b@mail.gmail.com> Message-ID: thanks mark :). Let me look at that option On Tue, Jan 19, 2010 at 9:53 AM, Mark Westling wrote: > I'm using Bunny inside a Rails 2.3 application that runs on Passenger. I > keep the connection in thread-local variables, like this: > > begin > b = (Thread.current[:bunny] ||= Bunny.new(:host => AMQ_HOST)) > b.start unless b.status == :connected > q = (Thread.current[queue] ||= b.queue(QUEUE_NAME)) > q.publish(message) > rescue Exception => e > Thread.current[:bunny] = nil # Force a reconnection > retry if (retries -= 1) >= 0 > end > > The first time this section of code runs it opens the connection and stores > it for reuse. The thread-local variables prevent multiple threads from > running into each other. This approach is working fine (but I'm open to > suggestions!). > > --Mark > > > On Mon, Jan 18, 2010 at 11:04 PM, vishnu wrote: > >> Hi, >> I was wondering if anyone on the list uses bunny with rails. Is there >> anything people do to keep the connection persistent across requests? By >> moving this code into the rails startup maybe? >> >> Also has anyone tried sharing the connection across multiple rails >> processes (does that even make sense?), or pooling the connections? >> thanks >> >> _______________________________________________ >> bunny-amqp-devel mailing list >> bunny-amqp-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/bunny-amqp-devel >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pathsny at gmail.com Wed Jan 20 11:04:18 2010 From: pathsny at gmail.com (vishnu) Date: Wed, 20 Jan 2010 21:34:18 +0530 Subject: [bunny-amqp-devel] dectecting a client timeout with bunny Message-ID: Hi Im attempting to use bunny to do the "rpc" mode communication where I listen on a temporary queue for 1 message with a timeout. Is there a way for me to detect after this step if the queue recieved a message or timedout (other than by maintaining state myself?). It would be possible for me to do this ofcourse, but I was wondering if the queue itself exposes this information in some way? thanks Vishnu -------------- next part -------------- An HTML attachment was scrubbed... URL: