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

Commit 8d36255

Browse files
authored
Merge pull request #6 from veshu/develop
changes for #/topcoder-archive/topcoder-platform-topcoder-x-receiver/issues/2
2 parents 8a001f3 + 0c08280 commit 8d36255

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

utils/kafka.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Kafka {
3737
let event;
3838
try {
3939
event = JSON.parse(item.message.value.toString('utf8'));
40+
event = JSON.parse(event.payload.value);
4041
} catch (err) {
4142
logger.error(`"message" is not a valid JSON-formatted string: ${err.message}`);
4243
return;
@@ -60,7 +61,21 @@ class Kafka {
6061
}
6162

6263
send(message) {
63-
return this.producer.send({topic: config.TOPIC, message: {value: message}});
64+
const data = JSON.stringify({
65+
topic: config.TOPIC,
66+
originator: 'topcoder-x-processor',
67+
timestamp: (new Date()).toISOString(),
68+
'mime-type': 'application/json',
69+
payload: {
70+
value: message
71+
}
72+
});
73+
return this.producer.send({
74+
topic: config.TOPIC,
75+
message: {
76+
value: data
77+
}
78+
});
6479
}
6580
}
6681

0 commit comments

Comments
 (0)