Apache Camel doTry doCatch无法捕获Akka骆驼异常

时间:2018-08-13 14:31:27

标签: apache-camel akka akka-camel

我们将XML DSL与Akka Camel(2.5.13)结合使用,发现当骆驼指向一个带有异常响应的bean时,它不会被Camel捕获。

我们的Scala代码:

private def replyError(exception: ChannelException) {
    log.error(exception.error)
    sender ! akka.actor.Status.Failure(exception)
}

我们的骆驼路线:

<route id="timer">
    <from uri="timer://test?period=3000&amp;delay=5000&amp;repeatCount=0"/>

    <doTry>

        <to uri="AKKABEAN"/>
        <doCatch>
            <exception>java.lang.Exception</exception>

            <log message="**********************************EXCEPTION HANDLED*******************************"/>

        </doCatch>
    </doTry>

</route>

在骆驼日志上:

  

启动actor ActorName时出错:具有相同名称的actor已经存在   运行akka.actor.InvalidActorNameException:演员名称[ActorName]   不是唯一的!在   akka.actor.dungeon.ChildrenContainer $ NormalChildrenContainer.reserve(ChildrenContainer.scala:129)   在akka.actor.dungeon.Children $ class.reserveChild(Children.scala:134)   在akka.actor.ActorCell.reserveChild(ActorCell.scala:431)在   akka.actor.dungeon.Children $ class.makeChild(Children.scala:272)在   akka.actor.dungeon.Children $ class.attachChild(Children.scala:48)在   akka.actor.ActorCell.attachChild(ActorCell.scala:431)在   akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:734)在   com.app.akka.App $ .createChannelActor(SwApp.scala:233)位于   com.app.akka.App $ .createActor(SwApp.scala:199)位于   com.app.akka.App $ .startChannelByName(SwApp.scala:137)位于   com.app.akka.actors.management.handleCommand(ManagementReceiver.scala:80)   在   com.app.akka.actors.management.manageChannel(ManagementReceiver.scala:66)   在   com.app.akka.actors.management.ManagementReceiver $$ anonfun $ receive $ 1.applyOrElse(ManagementReceiver.scala:52)   在   scala.PartialFunction $ AndThen.applyOrElse(PartialFunction.scala:189)   在akka.actor.Actor $ class.aroundReceive(Actor.scala:517)在   com.app.alla.actors.management.aroundReceive(ManagementReceiver.scala:14)   在akka.actor.ActorCell.receiveMessage(ActorCell.scala:588)在   akka.actor.ActorCell.invoke(ActorCell.scala:557)在   akka.dispatch.Mailbox.processMailbox(Mailbox.scala:258)位于   akka.dispatch.Mailbox.run(Mailbox.scala:225)在   akka.dispatch.Mailbox.exec(Mailbox.scala:235)在   akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)在   akka.dispatch.forkjoin.ForkJoinPool $ WorkQueue.runTask(ForkJoinPool.java:1339)   在   akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)   在   akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)   2018-08-13 10:11:45,807错误   org.apache.camel.processor.DefaultErrorHandler交付失败   (MessageId:ExchangeId上的ID-my-pc-1534165894710-0-25:   ID-my-pc-1534165894710-0-26)。尝试交付后已用尽:1   捕获:ChannelException(启动演员ActorName时出错:演员与   相同名称已经在运行,Map(MessageExchangeId->   ID-my-pc-1534165894710-0-26,面包屑ID->   ID-my-pc-1534165894710-0-26,COMMAND_TYPE-> START_ACTOR,ID_ACTOR->   ActorName))

如果我使用的是一个仅返回错误的bean,那么它工作得很好,例如:

<bean id="forced" class="java.lang.Exception">
    <constructor-arg index="0" value="This is forced"/>
</bean>

你知道是什么原因造成的吗?

0 个答案:

没有答案