I have this problem where I need to listen for the Redis queue when message gets sent to it. I tried this. However, this is not working. Is there anyway to keep listener running in the background while producer sends the message.
Copy code
suspend fun processRequest(request: Request): Result = coroutineScope {
val jobId = UUID.randomUUID().toString()
val deferredMessage = async {
redisOperations.listenToChannel(jobId).awaitFirst()
}
val deferredProducer = async(start = CoroutineStart.LAZY) {
adtMessageProducer.send(adtRequest, jobId)
}
deferredProducer.await()
deferredMessage.await().message
}
d
Dominaezzz
04/13/2020, 4:22 PM
Does that code not work? What does the method return then?
n
nicholasnet
04/13/2020, 5:06 PM
It just keeps on waiting and does not return anything