<div dir="ltr">Hi Sean,<div><br></div><div>As you probably know, the code in the php library is blocking, so unless an external event comes, there's no way to escape form the while loop that's reading from the channel. The wait method supports a timeout tho.</div>
<div><br></div><div>Regards,</div><div><br></div><div>Alvaro</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 25, 2014 at 3:16 PM, Sean Joyce <span dir="ltr"><<a href="mailto:sean.joyce@patientco.com" target="_blank">sean.joyce@patientco.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Michael - <div><br></div><div>Apologies for asking you to be pedantic, but I'm still a little hazy on how I would implement my desired behavior. </div>
<div><br></div><div>I actually have the 'quit' functionality embedded in my callback, though I stripped it out for my example for simplicity. With or without though, when I run my consumer, my code hits the '$this->channel->wait();' line and doesn't exit until an external event (new message) enters the queue. My preference is that a Consumer itself knows when it has sat idle long enough to terminate itself rather than having an external process monitor it.</div>

<div><br></div><div>Should this be done by subclassing AMQPChannel? Like I said, I'm still a little hazy. </div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Sean</div>
</font></span></div><div class="gmail_extra"><div class=""><br><br><div class="gmail_quote">On Tue, Jun 24, 2014 at 11:31 PM, Michael Klishin <span dir="ltr"><<a href="mailto:mklishin@gopivotal.com" target="_blank">mklishin@gopivotal.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 25 June 2014 at 00:43:15, Sean Joyce (<a href="mailto:sean.joyce@patientco.com" target="_blank">sean.joyce@patientco.com</a>) wrote:<br>


> > I've been trying to figure out where to call basic_cancel in<br>
> this code, but not finding the right solution. Any tips on how<br>
> to refactor and get what I want?<br>
><br>
> public function consume() {<br>
> $callback = function($msg) {<br>
> $pMsg = new ProcessorMessage();<br>
> $pMsg->onMessage($msg->body);<br>
> $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);<br>
> };<br>
><br>
> $this->channel->basic_qos(null, 1, null);<br>
> $this->channel->basic_consume($queue_name, '', false,<br>
> false, false, false, $callback);<br>
><br>
> while(count($this->channel->callbacks)) {<br>
> $this->channel->wait();<br>
> }<br>
><br>
> }<br>
<br>
</div>Sean,<br>
<br>
Take a look at the following 2 examples:<br>
<br>
<a href="https://github.com/videlalvaro/php-amqplib/blob/master/demo/amqp_consumer_non_blocking.php" target="_blank">https://github.com/videlalvaro/php-amqplib/blob/master/demo/amqp_consumer_non_blocking.php</a><br>
<a href="https://github.com/videlalvaro/php-amqplib/blob/master/demo/amqp_consumer.php#L52-54" target="_blank">https://github.com/videlalvaro/php-amqplib/blob/master/demo/amqp_consumer.php#L52-54</a> <br>
--<br>
MK<br>
<br>
Staff Software Engineer, Pivotal/RabbitMQ<br>
</blockquote></div><br><br clear="all"><div><br></div></div><div class="">-- <br><div dir="ltr"><div style="text-align:-webkit-auto;font-size:14px;font-family:Helvetica"><b style="color:rgb(111,116,122);text-align:-webkit-auto">Sean M. Joyce</b><br>

</div><div style="text-align:-webkit-auto;font-size:14px;font-family:Helvetica"><font color="#6f747a">Director of Product Engineering | Patientco</font></div><div style="text-align:-webkit-auto;font-size:14px;font-family:Helvetica">

<font color="#128b48"><a href="mailto:sean.joyce@patientco.com" target="_blank">sean.joyce<font color="#1155cc">@patientco.com</font></a></font></div>888.747.2455 x412<div style="text-align:-webkit-auto;font-size:14px;font-family:Helvetica">

<br></div><a href="http://info.patientco.com/himss" style="color:rgb(17,85,204);font-family:Helvetica;font-size:14px" target="_blank"><br></a><a href="http://info.patientco.com/happy-providers" style="color:rgb(17,85,204);font-family:Helvetica;font-size:medium" target="_blank"><img></a><br>

</div>
</div></div><div class="HOEnZb"><div class="h5">

<br>
<div><p style="margin:0in 0in 0.0001pt"><font>As a friendly reminder, never send Protected Health Information (PHI) via email. </font></p><p style="margin:0in 0in 0.0001pt"><font size="1"> </font></p></div><div><p style="margin:0in 0in 0.0001pt">
<font size="1"><span style="background-image:initial;background-repeat:initial">CONFIDENTIALITY NOTICE:</span>  The information contained in this email message may be privileged, confidential, and protected from disclosure. Any unauthorized use, printing, copying, disclosure, dissemination of or reliance upon this communication by persons other than the intended recipient may be subject to legal restriction or sanction. <span style="background-image:initial;background-repeat:initial">If you are not the intended recipient, you are hereby notified that you are not authorized to read, print, retain, copy, or disseminate this message, any part of it, or any attachments.</span>  If you think that you have received this email message in error, please reply to the sender and delete this email <span style="background-image:initial;background-repeat:initial">and any attachments and all copies thereof from your system without reading the content and destroy any printouts of the e-mail or attachments </span><span style="background-image:initial;background-repeat:initial">promptly.</span> </font></p>
</div></div></div><br>_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br></blockquote></div><br></div>