Skip to content

Commit c35c5f3

Browse files
committed
fix doc
1 parent 25af395 commit c35c5f3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

docs/guide/consuming.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,26 @@ $consumer->consume();
7070
**Consuming algorithm:**
7171
-------------------------------
7272

73-
????
73+
```$consumer->consume();``` - base realization of consumer.
7474

75+
If the message table does not exist, it will be created.
7576

77+
Next, will start endless loop ```while(true)``` to get the next message from the queue.
78+
if there are no messages, there will be a sustained seconds pause.
7679

80+
When the message is received, it will be processed. Job has priority over the processor.
7781

82+
If an uncaught error occurs, it will be caught and increment first processing attempt.
83+
84+
After several unsuccessful attempts, the message will status `\Simple\Queue\Status::FAILURE`.
85+
86+
If there are no handlers for the message, the message will status `\Simple\Queue\Status::UNDEFINED_HANDLER`.
87+
88+
> Messages are processed with statuses: `\Simple\Queue\Status::NEW` and `\Simple\Queue\Status::REDELIVERED`
7889
7990
<br>
8091

92+
8193
**Custom example for consuming:**
8294
-------------------------------
8395

src/Consumer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ public function consume(array $queues = []): void
204204
while (true) {
205205
if ($message = $this->fetchMessage($queues)) {
206206
try {
207+
208+
// TODO: set IN_PROCESS status
209+
207210
$this->processing($message);
208211
} catch (Throwable $throwable) {
209212
if ($message->getAttempts() >= $this->config->getNumberOfAttemptsBeforeFailure()) {
@@ -223,7 +226,9 @@ public function consume(array $queues = []): void
223226
// maybe lucky later
224227
}
225228
}
229+
continue;
226230
}
231+
sleep(1);
227232
}
228233
}
229234

0 commit comments

Comments
 (0)