Skip to content

Commit 1cd3bc8

Browse files
committed
check message value exists before processing messages
1 parent 803bd40 commit 1cd3bc8

File tree

1 file changed

+7
-2
lines changed
  • services/libs/queue/src/vendors/kafka

1 file changed

+7
-2
lines changed

services/libs/queue/src/vendors/kafka/client.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ export class KafkaQueueService extends LoggerBase implements IQueue {
221221

222222
this.log.trace({ topic: queueConf.name }, 'Subscribed to topic! Starting the consmer...')
223223
await consumer.run({
224-
eachMessage: async ({ message }: EachMessagePayload) => {
225-
if (this.isAvailable(maxConcurrentMessageProcessing)) {
224+
eachMessage: async ({ message, topic }: EachMessagePayload) => {
225+
if (message && message.value && this.isAvailable(maxConcurrentMessageProcessing)) {
226226
const now = performance.now()
227227

228228
this.log.trace(
@@ -243,6 +243,11 @@ export class KafkaQueueService extends LoggerBase implements IQueue {
243243
} finally {
244244
this.removeJob()
245245
}
246+
} else if (
247+
this.isAvailable(maxConcurrentMessageProcessing) &&
248+
(!message || !message.value)
249+
) {
250+
this.log.debug({ message, topic }, 'Received empty message, skipping...')
246251
} else {
247252
this.log.debug('Processor is busy, skipping message...')
248253
}

0 commit comments

Comments
 (0)