KonstantinCodes / messenger-kafka

Simple Kafka transport for Symfony Messenger.
MIT License
84 stars 35 forks source link

Error when using rdkafka 6.0.0 #56

Closed BeyerJC closed 2 years ago

BeyerJC commented 2 years ago

Hi,

after upgrading the rdkafka lib to 6.0.0 , the lib throws an error when trying to decode a message from kafka without headers or keys.

KafkaReceiver.php line 64:
  Typed property RdKafka\Message::$headers must not be accessed before initialization

The reason is that with version < 6.0.0 the headers and key property was initalized as null in the message. In the new version, the fields are missing if not set.

Example message with 6.0.0:

RdKafka\Message::__set_state(array(
   'err' => 0,
   'topic_name' => 'my-topic-name',
   'timestamp' => 1641293445730,
   'partition' => 0,
   'payload' => 'my payload ',
   'len' => 103,
   'key' => 'xxxx',
   'offset' => 38,
   'opaque' => NULL,
))
BeyerJC commented 2 years ago

I just saw that i accidentally locked the version to 0.14.0 and didnt get the updates from 0.15 where headers was initalized as empty array when not existant.

So i guess this issue is obsolet.