This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Actors question

1 reply
Craig Tataryn
Joined: 2010-10-08,
User offline. Last seen 1 year 38 weeks ago.

Hi, I have the following setup:

object CamelJockey extends Actor {
var camelCtx: CamelContext = null

def act() = {
loop {
react {
case "start" => {
val springCtx: ApplicationContext = new ClassPathXmlApplicationContext("spring/scribeBeans.xml")

camelCtx = springCtx.getBean("camelCtx").asInstanceOf[CamelContext]
camelCtx.start
}
case "stop" => camelCtx.stop; exit
case x: Any => println("Error: Unknown message! " + x)
}
}
}
}

/**
* Load up Camel
*
*/
object ScribeApp {
def main(args: Array[String]) {

CamelJockey ! "start"
Thread.sleep(10000);
println("Exiting...")

}
}

Essentially, ScribeApp is a bootstrapper for starting an Apache Camel context. The problem I'm facing is, it seems as though my case statement in the react block is never receiving the message "start". What happens instead is the app sleeps for 10secs, then prints out "Exiting...". Am I missing something (either code-wise, or understanding-wise)? I expected the "start" block to be executed and the app be kept alive by the loop in my actor.

Thanks,

Craig.

--
Craig Tataryn
site: http://www.basementcoders.com/
podcast: http://www.basementcoders.com/?feed=podcast
itunes: http://itunes.apple.com/podcast/the-basement-coders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
twitter: craiger

bmaso
Joined: 2009-10-04,
User offline. Last seen 2 years 40 weeks ago.
Re: Actors question

CamelJockey.start

And is this the same Craig from LeapFrog; involved in that awesome Gosling interview @ JavaOne [1]?

Brian Maso

[1] http://basementcoders.com/?p=721

Sent from my iPhone

On Oct 8, 2010, at 2:41 PM, Craig Tataryn wrote:

> Hi, I have the following setup:
>
> object CamelJockey extends Actor {
> var camelCtx: CamelContext = null
>
> def act() = {
> loop {
> react {
> case "start" => {
> val springCtx: ApplicationContext = new ClassPathXmlApplicationContext("spring/scribeBeans.xml")
>
> camelCtx = springCtx.getBean("camelCtx").asInstanceOf[CamelContext]
> camelCtx.start
> }
> case "stop" => camelCtx.stop; exit
> case x: Any => println("Error: Unknown message! " + x)
> }
> }
> }
> }
>
>
> /**
> * Load up Camel
> *
> */
> object ScribeApp {
> def main(args: Array[String]) {
>
> CamelJockey ! "start"
> Thread.sleep(10000);
> println("Exiting...")
>
> }
> }
>
>
> Essentially, ScribeApp is a bootstrapper for starting an Apache Camel context. The problem I'm facing is, it seems as though my case statement in the react block is never receiving the message "start". What happens instead is the app sleeps for 10secs, then prints out "Exiting...". Am I missing something (either code-wise, or understanding-wise)? I expected the "start" block to be executed and the app be kept alive by the loop in my actor.
>
> Thanks,
>
> Craig.
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast: http://www.basementcoders.com/?feed=podcast
> itunes: http://itunes.apple.com/podcast/the-basement-coders
> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
> twitter: craiger
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland