can we execute notification service after we respo...
# ktor
s
can we execute notification service after we respond the data
Copy code
get("/test") {
    call.respond("hello")
    sendNotification() // does this function call execute properly
}
v
I do it like this:
Copy code
suspendedTransactionAsync(<http://Dispatchers.IO|Dispatchers.IO>) {
    notificationsController.createNotificationForCommentVote(userId, commentId)
}
The call is before
Copy code
call.respond("hello")
But Your solution should work as well, but if for any reason the notification sending fails you won’t know unless you have some retry messaging que or something
a
IMHO It's better to call a notification function before
call.respond
because the latter executes the whole response pipeline.
☝️ 1
v
Yeap I agree with @Aleksei Tirman [JB], that is why I use the
suspendedTransactionAsync
this way I respond back without waiting for the notification to be send