Skip to content

Using Akka Actors this reads all text files in a directory and counts the number of words

License

Notifications You must be signed in to change notification settings

shehaaz/AkkaWordCounter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

###Implementation of Concurrency and Fault Tolerance Made Easy: An Akka Tutorial with Examples

Using Akka Actors this reads all text files in a directory and counts the number of words in each file.

This is an Intellij SBT project, so you can clone it and play around. I hope this helps someone! 😀

Example output:

Stream Complete: 2.txt Total Number of Words: 13084 Total Time: 148ms
Stream Complete: 4.txt Total Number of Words: 13084 Total Time: 113ms
Stream Complete: 8.txt Total Number of Words: 9100 Total Time: 107ms
Stream Complete: 5.txt Total Number of Words: 13084 Total Time: 160ms
Stream Complete: 6.txt Total Number of Words: 9100 Total Time: 99ms
Stream Complete: 7.txt Total Number of Words: 9100 Total Time: 109ms
Stream Complete: 3.txt Total Number of Words: 13084 Total Time: 238ms
Stream Complete: 10.txt Total Number of Words: 26168 Total Time: 306ms
Stream Complete: 9.txt Total Number of Words: 1256064 Total Time: 1267ms
Stream Complete: 1.txt Total Number of Words: 1256064 Total Time: 1283ms

Diagram

####Update: Don't create a new ActorSystem for each file.

Thanks Reddit User mmccaskill for pointing it out.

Read more here: [Do I need to re-use the same Akka ActorSystem or can I just create one every time I need one?] (http://stackoverflow.com/questions/10396552/do-i-need-to-re-use-the-same-akka-actorsystem-or-can-i-just-create-one-every-tim)

####Messages are sent to an Actor through one of the following methods.

  • ! means “fire-and-forget”, e.g. send a message asynchronously and return immediately. Also known as tell.
  • ? sends a message asynchronously and returns a Future representing a possible reply. Also known as ask

About

Using Akka Actors this reads all text files in a directory and counts the number of words

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages