Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da4dfcd

Browse files
committed
[consumption] Add onResult extension point.
1 parent 88a8291 commit da4dfcd

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

pkg/enqueue/Consumption/EmptyExtensionTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ public function onPreReceived(Context $context)
2525
{
2626
}
2727

28+
/**
29+
* @param Context $context
30+
*/
31+
public function onResult(Context $context)
32+
{
33+
}
34+
2835
/**
2936
* @param Context $context
3037
*/

pkg/enqueue/Consumption/ExtensionInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ public function onBeforeReceive(Context $context);
3131
*/
3232
public function onPreReceived(Context $context);
3333

34+
/**
35+
* Executed when a message is processed by a processor or a result was set in onPreReceived method.
36+
* BUT before the message status was sent to the broker
37+
* The consumption could be interrupted at this step but it exits after the message is processed.
38+
*
39+
* @param Context $context
40+
*/
41+
public function onResult(Context $context);
42+
3443
/**
3544
* Executed when a message is processed by a processor.
3645
* The context contains a status, which could not be changed.

pkg/enqueue/Consumption/QueueConsumer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ protected function doConsume(ExtensionInterface $extension, Context $context)
204204
$context->setResult($result);
205205
}
206206

207+
$extension->onResult($context);
208+
207209
switch ($context->getResult()) {
208210
case Result::ACK:
209211
$consumer->acknowledge($message);

0 commit comments

Comments
 (0)