Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8458287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:02:11+00:00 2026-06-10T13:02:11+00:00

I have a message queue in PHP which I use to process tasks, I

  • 0

I have a message queue in PHP which I use to process tasks, I caused a bug when inserting tasks and it has just inserted a bunch of bools (I usually pass objects through it).

I killed the process which reads the queue because it hung due to items not being removed.

My typical code which has worked fine for quite some time is:

    $mqst = msg_stat_queue($mqh);

    while ($mqst['msg_qnum']) {
        output('Queue is populated', O_DEBUG);
        msg_receive($mqh, 0, $msgtype, 2048, $data, true);
        $mqst = msg_stat_queue($mqh);
        if ($data instanceof \Core\Image) {
            $new_tasks[] = $data;
        } else {
            output('Got some odd data.. ' . print_r($data, true), O_ERROR);
        }
    }

From my terminal:

$ php -r '$mqh = msg_get_queue(12345, 0666);
          $mqst = msg_stat_queue($mqh); 
          $i = $mqst["msg_qnum"]; while ($i--) {
             msg_receive($mqh, 0, $type, 2048, $data, true);
             var_dump($type, $data); 
          }'

Output:

int(0)
bool(false)
int(0)
bool(false)
int(0)
bool(false)
int(0)
bool(false)
int(0)
bool(false)
int(0)
bool(false)
int(0)
bool(false)

I can repeat this indefinitely, they aren’t budging. I’ve tried to just remove the queue but to no success, the documentation states:

msg_remove_queue() destroys the message queue specified by the queue. Only use this function when all processes have finished working with the message queue and you need to release the system resources held by it.

However, I’ve killed the process and it isn’t very specific on releasing the resources. I’m not sure why the messages aren’t being popped off the queue after I receive them. Perhaps I’m missing something simple

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:02:12+00:00Added an answer on June 10, 2026 at 1:02 pm

    EDIT This answer was wrong.

    After studying the question more thoroughly, I think the following is the problem: the first message in the queue is larger than 2048 byes, which causes msg_receive to return an error. Because of this, the message is never removed from the queue, so it will stay intact.

    On next calls to the function, it will try to get the same entry, so it will fail again.

    My initial suggestion to make the msg_receive function the condition of the while loop would have made this clear immediately. (if it is indeed the solution).

    Solution: For now, add the MSG_NOERROR flag to the msg_receive function, just to see if the next message is indeed too large, and debug from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a message handler, which consumes from a JMS queue and that sends
I have a problem with my program, which is using IPC message queue. Althought
I have a message queue and use it from java code via MQQueueConnectionFactory .
I have to implement Message Queue on site which do 20K/Day write operation in
Here I have to send and receive dynamic data using a SysV message queue.
I have a queue of text messages in Redis. Let's say a message in
I have a web service , i add some extra class which have message
I have a message Queue and I am designing a WPF interface for it.
I understand the basics of a message queue system, but I have no idea
I have a BizTalk 2006 app which has a sendport using MSMQ. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.