第一次调用后开始执行异常

时间:2017-10-27 19:17:30

标签: java asynchronous akka actor

有一段代码在后端(play& Java)中运行。请求通过邮递员后端。后端定义了演员系统&在后端编译并首次运行时启动的演员。

[info] application - POST /lecture/audio (controllers.LectureController.createWithAudio) took 8139ms and returned 200 {"data":{"id":"59f382ac58d51a36985a5629"},"success":true}

当第一次请求时,一切都完美无缺。当发出第2次,第3次......请求时,它们会失败。生成以下错误 -

[info] application - getting file... in S3UsingActors
[error] application - 
! @75n6d8co5 - Internal server error, for (POST) [/lecture/audio] ->
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[CompletionException: akka.pattern.AskTimeoutException: Recipient[Actor[akka://sys/user/convertDropzoneAudio#1714762155]] had already been terminated. Sender[null] sent the message of type "common.Protocols.ConvertProtocol$AudioFilepartToFile".]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:293)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:220)
at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:100)
at play.filters.cors.AbstractCORSPolicy$$anonfun$2.applyOrElse(AbstractCORSPolicy.scala:146)
at play.filters.cors.AbstractCORSPolicy$$anonfun$2.applyOrElse(AbstractCORSPolicy.scala:145)
at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346)
at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
Caused by: java.util.concurrent.CompletionException: akka.pattern.AskTimeoutException: Recipient[Actor[akka://sys/user/convertDropzoneAudio#1714762155]] had already been terminated. Sender[null] sent the message of type "common.Protocols.ConvertProtocol$AudioFilepartToFile".
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
at common.settings.S3UsingActors.dropzonedAudioFile(S3UsingActors.java:83)
at controllers.LectureController.lambda$createWithAudio$9(LectureController.java:270)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:56)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:415)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
Caused by: akka.pattern.AskTimeoutException: Recipient[Actor[akka://sys/user/convertDropzoneAudio#1714762155]] had already been terminated. Sender[null] sent the message of type "common.Protocols.ConvertProtocol$AudioFilepartToFile".
at akka.pattern.AskableActorRef$.internalAsk$extension(AskSupport.scala:289)
at akka.pattern.AskSupport$class.ask(AskSupport.scala:76)
at akka.pattern.package$.ask(package.scala:41)
at akka.pattern.PatternsCS$.ask(Patterns.scala:349)
at akka.pattern.PatternsCS.ask(Patterns.scala)
at common.settings.S3UsingActors.dropzonedAudioFile(S3UsingActors.java:82)
at controllers.LectureController.lambda$createWithAudio$9(LectureController.java:270)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:56)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)

编辑 - 下面是“convertDropzoneAudio”actor的代码 -

@Inject
public S3UsingActors(Configuration configuration) {
    conf = configuration;

}

public static class ActorSysContainer {
    private ActorSystem sys;
    private ActorSysContainer() {
        sys = ActorSystem.create("sys");
    }

    public ActorSystem getSystem() {
        return sys;
    }

    private static ActorSysContainer instance = null;

    public static synchronized ActorSysContainer getInstance() {
        if (instance == null) {
            instance = new ActorSysContainer();
        }
        return instance;
    }
}



public static AudioDetail dropzonedAudioFile(Http.MultipartFormData.FilePart filepart, @Nonnull String filename) throws InterruptedException {

    if(convertActor == null) {
        convertActor = ActorSysContainer.getInstance().getSystem().actorOf(ConvertActor.getProps(), "convertDropzoneAudio");
    }
    Logger.info("getting file... in S3UsingActors");
    CompletableFuture<Object> getAudioDetail = ask(convertActor, new AudioFilepartToFile(filepart, filename, conf), 1000000).toCompletableFuture();
    AudioDetail audioDetail = (AudioDetail) getAudioDetail.join();
    return audioDetail;
}

}

0 个答案:

没有答案