开发者

If I have a queue (SQS, AMQP), how do I notify my worker servers when there is an object in it?

开发者 https://www.devze.com 2023-01-24 07:12 出处:网络
A lot of times my queue will remain empty. But when it开发者_高级运维 does fill up, how does that queue notify my server to execute a python script?

A lot of times my queue will remain empty. But when it开发者_高级运维 does fill up, how does that queue notify my server to execute a python script?

I could make it so that the python script hits the queue every 5 seconds, but that's silly.


You should have a consumer on the queue, which registers a callback. The consumer will then poll the queue and call the callback when an item is received.

You don't say how you're accessing the queue, but a library like carrot does this for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号