These are chat archives for arnaud-lb/php-rdkafka

7th
Aug 2018
tambach
@tambach
Aug 07 2018 10:42

Hi all !
I want to send an array just with four fields, i am trying this way
$topic->produce(RD_KAFKA_PARTITION_UA, 0, $result[$i]);

But consumer cant see it and i have the warning:
PHP Warning: RdKafka\ProducerTopic::produce() expects parameter 3 to be string, array given in /var/www/html/new-tests/producer-new-test.php on line 28

Is there any other way to do this?
Or what am i doing wrong?
Thank you in advance

karavzeka
@karavzeka
Aug 07 2018 10:44
$result[$i] contains array. It means that you have array of arrays.
you may use it that way
$topic->produce(RD_KAFKA_PARTITION_UA, 0, serialize($result[$i]));
and deserialize message in consumer
tambach
@tambach
Aug 07 2018 11:03
@karavzeka thank you so much, It works !
I used unserialize() in consumer and everything is fine.