Use an akka extension:
http://doc.akka.io/docs/akka/2.2.3/scala/extending-akka.html



On 13 January 2014 10:15, Markus Jais <markus.j...@yahoo.de> wrote:

> Hello,
>
> I need to integrate a Java library that is used to collects lot's of
> runtime information about errors, failures, etc.
> It has many data collectors. There may be better ways to do this but I
> need to use this library for current projects.
>
> The collectors should exist once per JVM (we are not using Akka cluster
> right now). If the JVM crashes, the data can be lost.
> Everything is in memory.
>
> How would I use such a singleton in the best way within an Akka/Spray
> service?
>
> I had the following ideas:
>
> 1) Just use a global singleton and something like a getInstance method
> which can be called form everywhere incl. each actor
>
> 2) Hide the singleton within an actor as a private member. Create only one
> such Actor and pass it around. Send messages to that actor and translate the
> message to calls to the data collector. This is ugly as I have to pass
> around the actor.
>
> 3) Use a trait similar ActorLogging which I can add to each Actor that
> needs those collectors and guarantee within the trait that there is only
> once instance.
>
>
>
> Are there any other options? Who has had to deal with a similar problem?
> Any recomendations for how to do this the Akka way?
>
> The old Java applications just use Spring and Singleton scop but the
> Scala/Akka services don't use Spring.
>
>
> Cheers,
>
> Markus
>
>  --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to