Symfony bundle which provides Kafka Symfony Messenger Transport which allows to decode messages including only event payload in the body based on mapping of topic name and message class name.
The bundle is highly inspired by work of koco/messenger-kafka.
This package is currently in the active development.
- PHP 7.2 or greater
- Symfony 4.4 or Symfony 5.x
Specify a DSN starting with either kafka://
or kafka+ssl://
.
There can be multiple brokers separated by ,
kafka://my-local-kafka:9092
kafka+ssl://my-staging-kafka:9093
kafka+ssl://prod-kafka-01:9093,kafka+ssl://prod-kafka-01:9093,kafka+ssl://prod-kafka-01:9093
The configuration options for conf
can be found
here.
It is highly recommended to set enable.auto.offset.store
to false
for consumers.
Otherwise every message is acknowledged, regardless of any error thrown by the message handlers.
framework:
messenger:
transports:
consumer:
dsn: '%env(KAFKA_URL)%'
options:
commitAsync: true
receiveTimeout: 10000
topics:
account.created: App\Account\Domain\Event\AccountWasCreated
conf:
enable.auto.offset.store: 'false'
group.id: 'my-group-id' # should be unique per consumer
security.protocol: 'sasl_ssl'
ssl.ca.location: '%kernel.project_dir%/config/kafka/ca.pem'
sasl.username: '%env(KAFKA_SASL_USERNAME)%'
sasl.password: '%env(KAFKA_SASL_PASSWORD)%'
sasl.mechanisms: 'SCRAM-SHA-256'
max.poll.interval.ms: '45000'
This bundle is being served only from private repository therefore it is required
to add proper repository into your composer.json
file.
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/easir/kafka-messenger-bundle.git"
}
]
}
Require the bundle implementation with Composer:
composer require easir/kafka-messenger-bundle
To enable the Bundle manually add it to the list of registered bundles
in the config/bundles.php
file of your project:
return [
// ...
Easir\KafkaMessengerBundle\KafkaMessengerBundle::class => ['all' => true],
];
This bundle enforces the Easir Code Standards during development using the PHP CS Fixer utility. Before committing any code, you can run the utility so it can fix any potential rule violations for you:
vendor/bin/phpcs
Use the issue tracker to report any issues you might have.
See the LICENSE file for license rights and limitations (MIT).