@@ -29,27 +29,36 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, (
29
29
} catch ( e ) {
30
30
logger . error ( 'Invalid message JSON.' )
31
31
logger . error ( e )
32
+
32
33
// ignore the message
33
- return
34
+ return co ( function * ( ) {
35
+ yield consumer . commitOffset ( { topic, partition, offset : m . offset } )
36
+ } )
34
37
}
35
38
36
39
if ( messageJSON . topic !== topic ) {
37
40
logger . error ( `The message topic ${ messageJSON . topic } doesn't match the Kafka topic ${ topic } .` )
38
41
// ignore the message
39
- return
42
+ return co ( function * ( ) {
43
+ yield consumer . commitOffset ( { topic, partition, offset : m . offset } )
44
+ } )
40
45
}
41
46
42
47
// Process only messages with scanned status
43
48
if ( messageJSON . topic === config . AVSCAN_TOPIC && messageJSON . payload . status !== 'scanned' ) {
44
49
logger . debug ( `Ignoring message in topic ${ messageJSON . topic } with status ${ messageJSON . payload . status } ` )
45
50
// ignore the message
46
- return
51
+ return co ( function * ( ) {
52
+ yield consumer . commitOffset ( { topic, partition, offset : m . offset } )
53
+ } )
47
54
}
48
55
49
56
if ( topic === config . SUBMISSION_CREATE_TOPIC && messageJSON . payload . fileType === 'url' ) {
50
57
logger . debug ( `Ignoring message in topic ${ messageJSON . topic } with file type as url` )
51
58
// ignore the message
52
- return
59
+ return co ( function * ( ) {
60
+ yield consumer . commitOffset ( { topic, partition, offset : m . offset } )
61
+ } )
53
62
}
54
63
55
64
return co ( function * ( ) {
@@ -66,11 +75,15 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, (
66
75
} )
67
76
// commit offset regardless of errors
68
77
. then ( ( ) => {
69
- consumer . commitOffset ( { topic, partition, offset : m . offset } )
78
+ return co ( function * ( ) {
79
+ yield consumer . commitOffset ( { topic, partition, offset : m . offset } )
80
+ } )
70
81
} )
71
82
. catch ( ( err ) => {
72
83
logger . error ( err )
73
- consumer . commitOffset ( { topic, partition, offset : m . offset } )
84
+ return co ( function * ( ) {
85
+ yield consumer . commitOffset ( { topic, partition, offset : m . offset } )
86
+ } )
74
87
} )
75
88
} )
76
89
0 commit comments