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
- It's recommended to send a number of messages without awaiting them, and then calling `flush` to ensure all messages are sent, rather than awaiting each message. This is more efficient.
185
+
Example:
186
+
```javascript
187
+
constkafka=newKafka({ kafkaJS: { /* ... */ }});
188
+
constproducer=kafka.producer();
189
+
awaitproducer.connect();
190
+
for (/*...*/) producer.send({ /* ... */});
191
+
awaitproducer.flush({timeout:5000});
192
+
```
193
+
194
+
However, in case it is desired to await every message, `linger.ms` should be set to 0, to ensure that the default batching behaviour does not cause a delay in awaiting messages.
195
+
Example:
196
+
```javascript
197
+
constkafka=newKafka({ kafkaJS: { /* ... */ }});
198
+
constproducer=kafka.producer({ 'linger.ms':0 });
199
+
```
184
200
185
201
* A transactional producer (with a `transactionId`) set, **cannot** send messages without initiating a transaction using `producer.transaction()`.
0 commit comments