Problems in implementation of Message Queuing feed program

Source: Internet
Author: User

Because of the project needs, build a lot of Message Queuing also queued processing tasks, each corresponding queue also has a feed program to feed messages

At first, it was easy to do this:

         while (true) {            $msg$query, Bpop ();             // message handlers        }

In this way the feed program will never quit at first, but there is a problem, once the message handler changes, if the process is not restarted after the manual kill process, the changes will not be loaded.

Another: It is said that the PHP process runs too long to generate garbage is difficult to reclaim, need to terminate the process to reclaim process garbage.

So I say the feed program is changed to the following way:

        Set_time_limit(0 ); $startTime= Time (); $maxDealNum= 1000;//Maximum processing times        $maxLifeTime= 12 * 3600;//maximum life cycle duration        $dealedNum= 0;  while(true ) {            $this->load->model (' item/category_frequently ')bdealmsg (); $dealedNum++; //The program exits when the maximum number of processing times or processing time is exceeded to clean up the memory garbage in a way that daemon restarts            if($dealedNum>$maxDealNum|| ( Time() -$startTime) >$maxLifeTime) {                return; }        }

After each processing of a message count, as well as record feed program start execution time, if 2 people are more than a certain threshold to let the program exit, so you can avoid a single long time hungry or perform frequent scenarios will not exit the process. When the message handler changes, it can be reloaded within the expected time

Problems in implementation of Message Queuing feed program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.