This is the gist of mine:<div><br></div><div><div>def get_channel(self):</div><div> """</div><div> Creates a persistent, ack based, non-exclusive queue/exchange using the routing key event</div>
<div> </div><div> Non-exclusivity allows any consumer to grab from the queue</div><div> """</div><div> channel = self.connection.channel()</div><div> </div><div> channel.queue_declare(queue='storage', durable=True, exclusive=False, auto_delete=False)</div>
<div> channel.exchange_declare(exchange='records', type='direct', durable=True, auto_delete=False)</div><div> channel.queue_bind(queue='storage', exchange='records', routing_key='event')</div>
<div> </div><div> channel.basic_consume(</div><div> queue='storage', no_ack=False, callback=self.recv_event_record, </div><div> consumer_tag=self.consumer_tag</div><div> )</div>
<div> </div><div> self.channel = channel</div><div> </div><div> return channel</div><div> </div><div> def recv_event_record(self, data):</div><div> """</div><div>
Cleans up the record, passes it on for processing</div><div> """</div><div> </div><div> item = cjson.decode(unicode(data.body).encode("utf8"))</div><div> </div>
<div> [processing...]</div><div> </div><div> <a href="http://logging.info">logging.info</a>('[id: ' + str(self.consumer_id) + '] Received queue item, processing...')</div><div> </div>
<div> self.process_record(record)</div><div> self.channel.basic_ack(data.delivery_tag)</div><div> </div><div> <a href="http://logging.info">logging.info</a>('[id: ' + str(self.consumer_id) + '] Processing complete, acknowledged.')</div>
<div><br></div><div> def process_record(self, item):</div><div> process(item)</div><div><br></div><div>def connect_consumer():</div><div> channel = get_channel()</div><div> </div><div> <a href="http://logging.info">logging.info</a>('Consumer started')</div>
<div> </div><div> while True:</div><div> channel.wait()</div><br><div class="gmail_quote">On Tue, Sep 8, 2009 at 7:01 AM, Chuck Remes <span dir="ltr"><<a href="mailto:cremes.devlist@mac.com">cremes.devlist@mac.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Aisha is mistaken. The ruby amqp library does not use libevent<br>
anywhere. It uses EventMachine under the covers which is a home-grown<br>
reactor written in C that uses select, poll and kqueue depending on<br>
the platform.<br>
<font color="#888888"><br>
cr<br>
</font><div><div></div><div class="h5"><br>
<br>
On Sep 8, 2009, at 8:33 AM, Ben Hood wrote:<br>
<br>
> Aisha,<br>
><br>
> Not wanting to hijack this thread another time, but....<br>
><br>
> On Mon, Sep 7, 2009 at 10:44 PM, Aisha<br>
> Fenton<<a href="mailto:aisha.fenton@gmail.com">aisha.fenton@gmail.com</a>> wrote:<br>
>> The library I'm using (<a href="http://github.com/celldee/bunny/tree/master" target="_blank">http://github.com/celldee/bunny/tree/master</a>)<br>
>> is<br>
>> synchronous only. I'm considering switching to (<a href="http://github.com/tmm1/amqp/tree/master" target="_blank">http://github.com/tmm1/amqp/tree/master</a><br>
>> ) which is async and uses libevent. However, I've read that there are<br>
>> problems with msg acknowledges in apps that use libevent, because the<br>
>> OS can buffer the ack responses. And although I'm not using ack<br>
>> yet, I<br>
>> want to in my production system.<br>
><br>
> I am interested as to what the specific issue is with sending acks<br>
> with libevent - are you saying that the app can issue an ack and this<br>
> can potentially go AWOL between the the libevent API returning and the<br>
> point it time when the AMQP frame is actually written to the socket?<br>
><br>
> Ben<br>
<br>
<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://mixpanel.com">http://mixpanel.com</a><br>Blog: <a href="http://blog.mixpanel.com">http://blog.mixpanel.com</a><br>
</div>