Class LimitConsumedMessagesExtension
A consumer extension to limit the number of messages that are processed.
This is a place holder until the upstream enqueue project extension is merged.
Property Summary
-
$messageConsumed protected
int
-
$messageLimit protected
int
Method Summary
-
__construct() public
-
onPostConsume() public
The method is called after SubscriptionConsumer::consume method exits. The consumption could be interrupted at this point.
-
onPreConsume() public
Executed at every new cycle before calling SubscriptionConsumer::consume method. The consumption could be interrupted at this step.
-
shouldBeStopped() protected
Check if the consumer should be stopped.
Method Detail
__construct() ¶ public
__construct(int $messageLimit)
Parameters
-
int
$messageLimit The number of messages to process before exiting.
onPostConsume() ¶ public
onPostConsume(PostConsume $context): void
The method is called after SubscriptionConsumer::consume method exits. The consumption could be interrupted at this point.
Parameters
-
PostConsume
$context The PostConsume context.
Returns
void
onPreConsume() ¶ public
onPreConsume(PreConsume $context): void
Executed at every new cycle before calling SubscriptionConsumer::consume method. The consumption could be interrupted at this step.
Parameters
-
PreConsume
$context The PreConsume context.
Returns
void
shouldBeStopped() ¶ protected
shouldBeStopped(Psr\Log\LoggerInterface $logger): bool
Check if the consumer should be stopped.
Parameters
-
Psr\Log\LoggerInterface
$logger The logger where messages will be logged.
Returns
bool