简体   繁体   中英

Using xdebug in PHP AMQPQueue::consume()

We are using RabbitMQ and would like to use xdebug inside of a consumer. We are using AMQPQueue to listen for messages on the queue. I can use xdebug up to AMQPQueue::consume() but once consume() is called I can not get a breakpoint. Any help would be great.

AMQPQueue::consume(callable $callback = null, $flags = AMQP_NOPARAM, $consumerTag = null) implemented in C ( amqp_queue.c:816 ) and when new message appears ( amqp_queue.c:908 ) on a channel (in terms of AMQP) calls callback function $callback ( amqp_queue.c:963 ). If you set breakpoint inside callback function, xdebug will stop on it when that callback will be called.

Under the hood there are endless loop with blocking socket reading which read everything on a channel and if it a message, pass it to callback. That loop breaks only when some exception happened (incl. in a callback) and when boolean false returned.

When no messages are on the channel consume() function will be running and blocking main PHP execution thread, so it may looks like application is hanging.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM