You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`clientId`: This is a user-supplied identifier for the client application, default `kafka-node-client`
22
22
*`zkOptions`: **Object**, Zookeeper options, see [node-zookeeper-client](https://github.com/alexguan/node-zookeeper-client#client-createclientconnectionstring-options)
23
+
*`noAckBatchOptions`: **Object**, when requireAcks is disabled on Producer side we can define the batch properties, 'noAckBatchSize' in bytes and 'noAckBatchAge' in milliseconds. The default value is `{ noAckBatchSize: null, noAckBatchAge: null }` and it acts as if there was no batch
23
24
24
25
### close(cb)
25
26
Closes the connection to Zookeeper and the brokers so that the node process can exit gracefully.
@@ -29,7 +30,18 @@ Closes the connection to Zookeeper and the brokers so that the node process can
29
30
## Producer
30
31
### Producer(client, [options])
31
32
*`client`: client which keeps a connection with the Kafka server.
32
-
*`options`: set `requireAcks` and `ackTimeoutMs` for producer, the default value is `{requireAcks: 1, ackTimeoutMs: 100}`
33
+
*`options`: options for producer,
34
+
35
+
```js
36
+
{
37
+
// Configuration for when to consider a message as acknowledged, default 1
38
+
requireAcks:1,
39
+
// The amount of time in milliseconds to wait for all acks before considered, default 100ms
40
+
ackTimeoutMs:100,
41
+
// Partitioner type (default = 0, random = 1, cyclic = 2, keyed = 3), default 0
42
+
partitionerType:2
43
+
}
44
+
```
33
45
34
46
```js
35
47
var kafka =require('kafka-node'),
@@ -49,9 +61,10 @@ var kafka = require('kafka-node'),
49
61
```js
50
62
{
51
63
topic:'topicName',
52
-
messages: ['message body'],// multi messages should be a array, single message can be just a string or a KeyedMessage instance
53
-
partition:0, //default 0
54
-
attributes:2, // default: 0
64
+
messages: ['message body'], // multi messages should be a array, single message can be just a string or a KeyedMessage instance
65
+
key:'theKey', // only needed when using keyed partitioner
0 commit comments