I have this problem where I need to listen for the...
# coroutines
n
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
Does that code not work? What does the method return then?
n
It just keeps on waiting and does not return anything