talentrydev/message-broker-bundle

Symfony bundle integrating talentrydev/message-broker library

4.0.0 2024-02-14 10:25 UTC

This package is auto-updated.

Last update: 2024-04-14 11:41:33 UTC


README

This is a Symfony bundle used for integrating talentrydev/message-broker library into a Symfony project.

Installing

  • Run:
composer require talentrydev/message-broker-bundle
  • Add the MessageBrokerBundle to your kernel's registerBundles method:
return [
    //...
    new \Talentry\MessageBrokerBundle\MessageBrokerBundle();
];

Configuring

Bundle exposes the following configuration:

OptionTypeDefault valueAvailable valuesRequiredDescription
aws_regionstringeu-central-1Any valid AWS regiononly when using sns or sqs implementationAWS region
channelsarray-See belownoUsed for configuring channels and serialization strategies
kafkaarray-See belownoUsed for configuring Kafka
namespacestring-Any stringnoUsed for prefixing SQS queue names
publisher_implementationstringsqssqs,sns,array,kafkayesSelects the message broker implementation used for publishing messages
sns_endpointstring-Any valid URLnoAllows using a custom AWS SNS implementation (eg. localstack); useful for testing
sns_topic_arnstring-Any valid AWS SNS ARNonly when using sns publisher implementationARN of the SNS topic to which messages will be published
sqs_endpointstring-Any valid URLnoAllows using a custom AWS SQS implementation (eg. localstack); useful for testing
subscriber_implementationstringsqssqs,array,kafkayesSelects the message broker implementation used for receiving messages

Channels configuration:

OptionTypeDefault valueAvailable valuesRequiredDescription
namestring-Any valid channel nameyesName of the channel
serialization_strategystring-Valid serialization strategy class nameyesFQCN of the class implementing MessageSerializationStrategy

Kafka configuration:

OptionTypeDefault valueAvailable valuesRequiredDescription
auto_offset_resetstringearliestlatest, earliest, noneonly when using kafka implementationhttps://kafka.apache.org/documentation/#consumerconfigs_auto.offset.reset
broker_liststring-Valid list of host namesonly when using kafka implementationhttps://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.addbrokers.html
enable_partition_eofstringtruetrue or falseonly when using kafka implementationhttps://docs.confluent.io/3.2.1/clients/librdkafka/CONFIGURATION_8md.html
enable_auto_commitstringfalsetrue or falseonly when using kafka implementationhttps://kafka.apache.org/documentation/#consumerconfigs_enable.auto.commit
loglevel | integer | 3 | Any LOG* PHP constantonly when using kafka implementationSets the log level of the Kafka PHP module
max_poll_interval_msinteger300000Any integeronly when using kafka implementationhttps://kafka.apache.org/documentation/#consumerconfigs_max.poll.interval.ms
session_timeout_msinteger45000Any integeronly when using kafka implementationhttps://kafka.apache.org/documentation/#connectconfigs_session.timeout.ms

Important considerations when using kafka implementation

  • In order to use the kafka implementation, you need to install the php-rdkafka extension: https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/index.html
  • There is no support for dead letter queues
  • Horizontal scaling of the consumers is rather limited: the number of consumers cannot exceed the number of partitions on the given topic
  • If the processing of the message takes longer than the max.poll.interval.ms, the consumer will be kicked out of the group and won't receive any more messages