@@ -468,8 +468,9 @@ int kafka_produce_report(rd_kafka_t *r, const char *topic, char *msg, int msg_le
468468 return 0 ;
469469}
470470
471- int kafka_produce_batch (rd_kafka_t * r , char * topic , char * * msg , int * msg_len , int msg_cnt , int report )
471+ int kafka_produce_batch (rd_kafka_t * r , char * topic , char * * msg , int * msg_len , int msg_cnt , int report , long timeout )
472472{
473+ char errstr [512 ];
473474 rd_kafka_topic_t * rkt ;
474475 struct produce_cb_params pcb = {msg_cnt , 0 , 0 , 0 , 0 , NULL };
475476 void * opaque ;
@@ -496,6 +497,24 @@ int kafka_produce_batch(rd_kafka_t *r, char *topic, char **msg, int *msg_len, in
496497 /* Topic configuration */
497498 topic_conf = rd_kafka_topic_conf_new ();
498499
500+ char timeoutStr [64 ];
501+ snprintf (timeoutStr , 64 , "%lu" , timeout );
502+ if (rd_kafka_topic_conf_set (topic_conf , "message.timeout.ms" , timeoutStr , errstr , sizeof (errstr )) != RD_KAFKA_CONF_OK )
503+ {
504+ if (log_level )
505+ {
506+ openlog ("phpkafka" , 0 , LOG_USER );
507+ syslog (
508+ LOG_ERR ,
509+ "Failed to configure topic param 'message.timeout.ms' to %lu before producing; config err was: %s" ,
510+ timeout ,
511+ errstr
512+ );
513+ }
514+ rd_kafka_topic_conf_destroy (topic_conf );
515+ return -3 ;
516+ }
517+
499518 /* Create topic */
500519 rkt = rd_kafka_topic_new (r , topic , topic_conf );
501520
0 commit comments