Upgrade Guide
v1.11.x
to v1.12.x
Upgrading from High impact changes
- Renamed method
stopConsume
tostopConsuming
. - A new
onStopConsuming
method was added to the\Junges\Kafka\Contracts\CanConsumeMessages
contract. - The former
stopConsume
method (nowstopConsuming
) doesn't accept a callback anymore. Instead, you must use the newly addedonStopConsuming
method to specify the callback that should run when the consumer stops consuming messages.
// Laravel Kafka v1.11.x: $stoppableConsumer = Kafka::createConsumer(['topic']) ->withConsumerGroupId('group') ->withHandler(function ($message) use ($stoppableConsumer) { // Handle the message if ($shouldStopConsuming) { $stoppableConsumer->stopConsume(function () { // Run this callback when stop consuming }) } }) ->build(); // In Laravel Kafka v1.12.x: $stoppableConsumer = Kafka::createConsumer(['topic']) ->withConsumerGroupId('group') ->withHandler(function ($message) use ($stoppableConsumer) { // Handle the message }) ->build() ->onStopConsuming(function () { // This will run when the consumer stops consuming messages. })