如何在保持JDBC事务并行运行的同时向用户返回响应?

问题描述 投票:0回答:1

我正在使用播放2.6。

我需要做这样的事情:

1-Receive an HTTP request 2-Start a job to insert hundreds of thousands of rows in the Database, which might take hours to complete 3-Return an HTTP response immediately after starting the job 4-Keep the job running and send an email to the user when it's finished

我找到了一些与Akka https://www.playframework.com/documentation/2.6.x/JavaAkka有关的文档,但我不知道这会是吗?我在正确的道路上吗?

playframework playframework-2.0
1个回答
0
投票
您正在寻找Java异步:

  • Java CompletionStage类似于JavaScript Promise(结果的承诺)。因此它这样做:return promiseOfResult而不是return result以避免阻塞。

    请注意,默认情况下操作是异步的:

  • © www.soinside.com 2019 - 2024. All rights reserved.