This is the piece of code that sends the requests twice every time you call it
suspend fun requestSimulation(simulationRequest: SimulationRequest): Boolean {
val accepted = WebClient.create(simulationServiceHost)
.post()
.uri(simulationEndpoint)
.bodyValue(simulationRequest)
.retrieve()
.bodyToFlux(Boolean::class.java)
accepted.subscribe { bool: Boolean -> logger.info(bool.toString()) }
return accepted.awaitSingle()
}
This is the modified code that fixed the issue
suspend fun requestSimulation(simulationRequest: SimulationRequest): Boolean {
return WebClient.create(simulationServiceHost)
.post()
.uri(simulationEndpoint)
.bodyValue(simulationRequest)
.retrieve()
.bodyToMono(Boolean::class.java)
.awaitSingle()
}