mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-20 01:36:50 +00:00
fix: wait for kafka to accept message and return success than
This commit is contained in:
parent
e9e7139ca4
commit
cf8c5a8692
@ -27,18 +27,27 @@ import org.springframework.stereotype.Component
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
class KafkaMtbFileSender(
|
class KafkaMtbFileSender(
|
||||||
private val kafkaTemplate: KafkaTemplate<String, String>,
|
private val kafkaTemplate: KafkaTemplate<String, String>,
|
||||||
private val objectMapper: ObjectMapper
|
private val objectMapper: ObjectMapper
|
||||||
) : MtbFileSender {
|
) : MtbFileSender {
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(KafkaMtbFileSender::class.java)
|
private val logger = LoggerFactory.getLogger(KafkaMtbFileSender::class.java)
|
||||||
|
|
||||||
override fun send(mtbFile: MtbFile): MtbFileSender.Response {
|
override fun send(mtbFile: MtbFile): MtbFileSender.Response {
|
||||||
return try {
|
return try {
|
||||||
kafkaTemplate.sendDefault(String.format("{\"pid\": \"%s\", \"eid\": \"%s\"}", mtbFile.patient.id,
|
var result = kafkaTemplate.sendDefault(
|
||||||
mtbFile.episode.id), objectMapper.writeValueAsString(mtbFile))
|
String.format(
|
||||||
logger.debug("Sent file via KafkaMtbFileSender")
|
"{\"pid\": \"%s\", \"eid\": \"%s\"}", mtbFile.patient.id,
|
||||||
MtbFileSender.Response(MtbFileSender.ResponseStatus.UNKNOWN)
|
mtbFile.episode.id
|
||||||
|
), objectMapper.writeValueAsString(mtbFile)
|
||||||
|
)
|
||||||
|
if (result.get() != null) {
|
||||||
|
logger.debug("Sent file via KafkaMtbFileSender");
|
||||||
|
MtbFileSender.Response(MtbFileSender.ResponseStatus.SUCCESS);
|
||||||
|
} else {
|
||||||
|
MtbFileSender.Response(MtbFileSender.ResponseStatus.ERROR)
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.error("An error occured sending to kafka", e)
|
logger.error("An error occured sending to kafka", e)
|
||||||
MtbFileSender.Response(MtbFileSender.ResponseStatus.UNKNOWN)
|
MtbFileSender.Response(MtbFileSender.ResponseStatus.UNKNOWN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user