-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_producer.php
More file actions
21 lines (21 loc) · 882 Bytes
/
test_producer.php
File metadata and controls
21 lines (21 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
require_once('/root/kafka-php/autoload.php');
$kafka_config = array(
'KF_ZK_HOSTS' => '10.10.10.117:2181/kafka/GSTest01',
'KF_BROKER_HOSTS' => '10.10.10.117:9093,10.10.10.117:9092,10.10.10.111:9092,10.10.10.113:9092',
'KF_ZK_TIMEOUT' => 1000,
'KF_SEND_TIMEOUT' => 100
);
$zk_hosts = $kafka_config['KF_ZK_HOSTS'];
$broker_hosts = $kafka_config['KF_BROKER_HOSTS'];
$zk_timeout = $kafka_config['KF_ZK_TIMEOUT'];
$send_timeout = $kafka_config['KF_SEND_TIMEOUT'];
$produce = Kafka\Produce::getInstance($zk_hosts, $zk_timeout, $broker_hosts);
//$consumer = Kafka\Consumer::getInstance($this->_zk_hosts, $this->_zk_timeout);
//$re=$produce->getClient()->getTopicDetail("liupeng2",true);
$produce->setTimeOut($send_timeout);
$produce->setMessages("liupeng2", 3, array("hello"));
$produce->setRequireAck(1);
$re=$produce->send(1);
var_dump($re);
?>