diff --git a/lib/match.js b/lib/match.js index 3b4bc4f..e34692b 100644 --- a/lib/match.js +++ b/lib/match.js @@ -230,6 +230,12 @@ const runGtfsMatching = async (cfg, opt = {}) => { matched: isMatched ? '1' : '0', cached: isCached ? '1' : '0', }, matchingTime / 1000) + + if (!isMatched) { + // > Indicate to the JetStream server that processing of the message failed and that the message should not be sent to the consumer again. + // https://nats-io.github.io/nats.js/jetstream/interfaces/JsMsg.html#term + msg.term() + } } catch (err) { if (isProgrammerError(err)) { throw err @@ -258,6 +264,10 @@ const runGtfsMatching = async (cfg, opt = {}) => { dataSlice: data.slice(0, 100).toString('utf8'), }, 'processing AUS IstFahrt msg') + // > Indicate to the JetStream server that processing of the message is on going, and that the ack wait timer for the message should be reset preventing a redelivery. + // https://nats-io.github.io/nats.js/jetstream/interfaces/JsMsg.html#working + msg.working() + // update NATS metrics { const {