diswebru/laravel-kafka-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

diswebru/laravel-kafka-tools

最新稳定版本:1.0.0

Composer 安装命令:

composer require diswebru/laravel-kafka-tools

包简介

tools for mateusjunges/laravel-kafka

README 文档

README

Installation

composer require diswebru/laravel-kafka-tools

Examples

Sending a message to the tests topic

use Diswebru\LaravelKafkaTools\Kafka;

Kafka::publish('topic', ['message-key' => 'message-value']);

Retrieve unprocessed messages from the tests topic and terminate the process

use Diswebru\LaravelKafkaTools\Kafka;

Kafka::consumer('topic', function (ConsumerMessage $message) {
        $data = $message->getBody();
        
        if (!isset($data['message-key']) && $data['message-key'] != 'message-value') {
            // There will be no commit
            throw new \Exception('Error message');
        }
    });

Retrieve unprocessed messages from the tests topic and terminate the process using mateusjunges/laravel-kafka

use Diswebru\LaravelKafkaTools\Infrastructure\Factories\ManuallyCommitterFactory;
use Junges\Kafka\Contracts\ConsumerMessage;
use Junges\Kafka\Facades\Kafka;

Kafka::consumer()
    ->subscribe('topic')
    ->withOptions([
        'enable.auto.commit' => 'false',
        'auto.offset.reset' => 'earliest'
    ])
    ->stopAfterLastMessage()
    ->usingCommitterFactory(new ManuallyCommitterFactory())
    ->withHandler(function (ConsumerMessage $message) {
        $data = $message->getBody();
        
        if (!isset($data['message-key']) && $data['message-key'] != 'message-value') {
            // There will be no commit
            throw new \Exception('Error message');
        }
    })
    ->build()
    ->consume();

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-05