- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Actors question
Fri, 2010-10-08, 22:41
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
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
>