akka/akka-core

Akka Camel responding with Exception not being caught by Camel

Open

#25,470 opened on Aug 13, 2018

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Scala (3,547 forks)batch import
1 - triagedhelp wantedt:camel

Repository metrics

Stars
 (13,277 stars)
PR merge metrics
 (Avg merge 8d 19h) (10 merged PRs in 30d)

Description

We are using XML DSL with Akka Camel (2.5.13), and found that when a camel <to> points to a bean, which answers with an Exception, it is not caught by Camel.

Our Scala code:

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

Our Camel route:

<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>

On camel log:

Error starting actor ActorName: actor with the same name is already running akka.actor.InvalidActorNameException: actor name [ActorName] is not unique! at akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:129) at akka.actor.dungeon.Children$class.reserveChild(Children.scala:134) at akka.actor.ActorCell.reserveChild(ActorCell.scala:431) at akka.actor.dungeon.Children$class.makeChild(Children.scala:272) at akka.actor.dungeon.Children$class.attachChild(Children.scala:48) at akka.actor.ActorCell.attachChild(ActorCell.scala:431) at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:734) at com.app.akka.App$.createChannelActor(SwApp.scala:233) at com.app.akka.App$.createActor(SwApp.scala:199) at com.app.akka.App$.startChannelByName(SwApp.scala:137) at com.app.akka.actors.management.handleCommand(ManagementReceiver.scala:80) at com.app.akka.actors.management.manageChannel(ManagementReceiver.scala:66) at com.app.akka.actors.management.ManagementReceiver$$anonfun$receive$1.applyOrElse(ManagementReceiver.scala:52) at scala.PartialFunction$AndThen.applyOrElse(PartialFunction.scala:189) at akka.actor.Actor$class.aroundReceive(Actor.scala:517) at com.app.alla.actors.management.aroundReceive(ManagementReceiver.scala:14) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:588) at akka.actor.ActorCell.invoke(ActorCell.scala:557) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:258) at akka.dispatch.Mailbox.run(Mailbox.scala:225) at akka.dispatch.Mailbox.exec(Mailbox.scala:235) at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) 2018-08-13 10:11:45,807 ERROR org.apache.camel.processor.DefaultErrorHandler Failed delivery for (MessageId: ID-my-pc-1534165894710-0-25 on ExchangeId: ID-my-pc-1534165894710-0-26). Exhausted after delivery attempt: 1 caught: ChannelException(Error starting actor ActorName: actor with the same name is already running, Map(MessageExchangeId -> ID-my-pc-1534165894710-0-26, breadcrumbId -> ID-my-pc-1534165894710-0-26, COMMAND_TYPE -> START_ACTOR, ID_ACTOR -> ActorName))

If I use a bean that just returns an error it works perfectly fine, example:

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

Using that bean in the <to> works perfectly.

Contributor guide