Hi! Before upgrading to Ktor 3.0 i had this code: ...
# ktor
m
Hi! Before upgrading to Ktor 3.0 i had this code:
Copy code
fun Route.mottakApi(
    readAndParseFileService: ReadAndParseFileService = ReadAndParseFileService(),
    validateTransaksjonService: ValidateTransaksjonService = ValidateTransaksjonService(),
    writeToFileService: WriteToFileService = WriteToFileService(),
    sendUtbetalingTransaksjonToOppdragZService: SendUtbetalingTransaksjonToOppdragZService =
        SendUtbetalingTransaksjonToOppdragZService(
            mqBatchSize = PropertiesConfig.MQProperties().mqBatchSize,
        ),
    sendTrekkTransaksjonToOppdragZService: SendTrekkTransaksjonToOppdragZService =
        SendTrekkTransaksjonToOppdragZService(
            mqBatchSize = PropertiesConfig.MQProperties().mqBatchSize,
        ),
    avstemmingService: AvstemmingService = AvstemmingService(),
) {
    route("api/v1") {
        get("readParseFileAndValidateTransactions") {
            launch(<http://Dispatchers.IO|Dispatchers.IO>) {
                readAndParseFileService.readAndParseFile()
                validateTransaksjonService.validateInnTransaksjon()
                writeToFileService.writeReturnFile()
            }
            call.respond(HttpStatusCode.OK, "ReadAndParseFile av filer har startet, sjekk logger for status")
        }
launch
is coming from:
Copy code
import kotlinx.coroutines.launch
After upgrading to Ktor 3.0 i get this error:
solved 1
e
Hey @mudasar187, could you try using
Copy code
call.launch
instead?
m
Now its works, is that a new change in Ktor 3.0?
e
Yep, now all jobs are explicitly launching on the request context
m
Thank you!