i have a java application which has various Agents(Java Algo’s) which listen to messages and process them . Each agent executes these messages on a single thread where these messages are added in a blocking queue to be processed one by one . This processing on a single message involves i/o with a remote machine . Overtime , these threads get hung one by one due to an inherent Bug in java . They say the bug is fixed but its not , i have run it on all latest java versions and tried all workarounds for a month now .So, i am planning to move to scala actors .
Below are my questions :
-
Is the above requirement possible in scala actors and will it overcome the java bug ?
-
A simple overview of how to do it if it’s possible 🙂
P.S : i have been reading through the programming in scala book for getting the syntax and basic features .
For the first question the answer is yes , scala actors do overcome the bug mentioned due to its actor concurrency model . I have been using it over the past 2 weeks with no downtime . Actors are lightweight , easy to scale and are definetly performing faster than my threaded agents in java . The memory consumption has come down as well weirdly.
Now for the implementation part , writing actors is easy once you know the basics of scala . If you are using eclipse + maven plugin m2eclipse-scala is the place to start . i have successfully built an osgi bundle using the steps mentioned there . The scala ide is a work in progress and is a bit of pain to write code .
Now for the scala actors , working with their message inbox’s is hard . Accessing them is restricted and they seem to easily get out of memory when the rate of message’s coming in is higher than the rate at which the actor could process . Akka actors definitely have an advantage here in by enabling us to set the max mailbox size,mailbox-push-timeout..etc or you can have your own inbox implementation .
Thanks for you help
sanre6