2

I'm using rabbit with PHP on osx.

Simple example. I've one durable queue with 50K durable messages. I run the consumer script. There is example of that script:

...
while ($this->run) {
    if ($message = $channel->basic_get("testq.{$this->id}")) {
        $channel->basic_ack($message->delivery_info['delivery_tag']);
        echo "{$message->delivery_info['routing_key']} (".$message->get('priority')."): {$message->body}\n";
        $sleep = 15000; // usecs
    } else {
        usleep($sleep);
    }
    ...
}
...

After running consumer script i see in rabbit webadmin that messages count from that queue is lowering.

Seems everything is OK.

If i kill php consumer script with CTRL+C and script till stopping was consumed for example 10K messages i see in that 40K messages left in queue.

It's OK.

But if i kill rabbitmq with kill -9 or CRLT+C, while consumer script is running (i want to simulate crash), after restart messages count in that queue restores to 50K ..

I don't understand why? where may be the problem?

4

0 回答 0