@@ -47,6 +47,7 @@ If partition === null && key === null, then use Round Robin to select partition
4747``` php
4848use longlang\phpkafka\Producer\Producer;
4949use longlang\phpkafka\Producer\ProducerConfig;
50+ use longlang\phpkafka\Protocol\RecordBatch\RecordHeader;
5051
5152$config = new ProducerConfig();
5253$config->setBootstrapServer('127.0.0.1:9092');
@@ -57,6 +58,14 @@ $topic = 'test';
5758$value = (string) microtime(true);
5859$key = uniqid('', true);
5960$producer->send('test', $value, $key);
61+
62+ // set headers
63+ // key-value or use RecordHeader
64+ $headers = [
65+ 'key1' => 'value1',
66+ (new RecordHeader())->setHeaderKey('key2')->setValue('value2'),
67+ ];
68+ $producer->send('test', $value, $key, $headers);
6069```
6170
6271## Send batch messages
@@ -83,14 +92,17 @@ $producer->sendBatch([
8392```
8493
8594## SASL Support
95+
8696### Configuration
97+
8798| Key | Description | Default |
8899| - | - | - |
89100| type | SASL Authentication Type. PLAIN is `` \longlang\phpkafka\Sasl\PlainSasl::class `` | ''|
90101| username | username | '' |
91102| password | password | '' |
92103
93104** Example**
105+
94106``` php
95107use longlang\phpkafka\Producer\ProducerConfig;
96108use longlang\phpkafka\Producer\Producer;
@@ -106,13 +118,14 @@ $producer = new Producer($config);
106118// .... Your Business Code
107119```
108120
109-
110121## SSL Support
122+
111123Class ` longlang\phpkafka\Config\SslConfig `
112124
113125> You can pass an array to a constructor.
114126
115127### Configuration keys
128+
116129| Key | Description | Default |
117130| - | - | - |
118131| open | Enable SSL | ` false ` |
@@ -145,4 +158,4 @@ $sslConfig->setCafile("/kafka-client/.github/kafka/cert/ca-cert");
145158$config->setSsl($sslConfig);
146159$producer = new Producer($config);
147160// .... Your Business Code
148- ```
161+ ```
0 commit comments