Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 2b324ea

Browse files
Add delay
1 parent b13ff0e commit 2b324ea

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

ReadMe.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The following parameters can be set in config files or in env variables:
3535
- KAFKA_GROUP_ID: the Kafka group id, default value is 'legacy-challenge-processor'
3636
- KAFKA_ERROR_TOPIC: The kafka error topic.
3737
- BUSAPI_URL: Bus API URL
38+
- RETRY_TIMEOUT: The timeout to retry processing the same message
3839
- CREATE_CHALLENGE_TOPIC: the create challenge Kafka message topic, default value is 'challenge.notification.create'
3940
- UPDATE_CHALLENGE_TOPIC: the update challenge Kafka message topic, default value is 'challenge.notification.update'
4041
- AUTH0_URL: Auth0 URL, used to get TC M2M token

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
KAFKA_GROUP_ID: process.env.KAFKA_GROUP_ID || 'legacy-challenge-processor',
1616
KAFKA_ERROR_TOPIC: process.env.KAFKA_ERROR_TOPIC || 'common.error.reporting',
1717
BUSAPI_URL: process.env.BUSAPI_URL || 'https://api.topcoder-dev.com/v5',
18+
RETRY_TIMEOUT: process.env.RETRY_TIMEOUT || 10 * 1000,
1819

1920
// Topics to listen
2021
CREATE_CHALLENGE_TOPIC: process.env.CREATE_CHALLENGE_TOPIC || 'challenge.notification.create',

src/services/ProcessorService.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,12 @@ async function processUpdate (message) {
293293
} catch (e) {
294294
// postponne kafka event
295295
logger.info('Challenge does not exist yet. Will post the same message back to the bus API')
296-
await helper.postBusEvent(config.UPDATE_CHALLENGE_TOPIC, message.payload)
296+
await new Promise((resolve) => {
297+
setTimeout(async () => {
298+
await helper.postBusEvent(config.UPDATE_CHALLENGE_TOPIC, message.payload)
299+
resolve()
300+
}, config.RETRY_TIMEOUT)
301+
})
297302
return
298303
}
299304
try {

0 commit comments

Comments
 (0)