Hi,

On Sun, Apr 5, 2015 at 5:10 PM, AL <123...@gmail.com> wrote:

> Hi
> Just want to consult if this make sense .
> I have an actor that uses as a service to fetch data from the db .
> for accessing the DB we have a Java Spring project with hibernate and Jpa
> Repository
> what is the best participate for testings :
> the actor should receive as a parameter the repository something like this
> :
> class FooService(invoicesRepo:InvoicesRepository,...more repositories goes
> here ... ) extends Actor ....
> and while testing to send mock[InvoicesRepository]
>
> two questions :
> is that make sense to use an actor to fetch/update data from the db (tried
> to find examples at typesafe activator templates but couldn't really find
> actors )?
>

Do you have a particular reason you started to think about encapsulating DB
access to an actor? Actors are about distribution and about encapsulating
state that can be safely accessed concurrently. There are situations where
one could choose to put all the code that accesses the DB to an actor so
access to DB is only from a one thread at a time, but that is a very
specific requirement.


> if the answer is yes - is it a good practice to send the repository to
> actor ? or is it better use dependency injection
>

When sending dependencies in a message you need to make sure that your
actor does not start handling business messages until dependencies are sent
in. Also you will have to take care of actor restarts. Therefore passing in
dependencies as constructor arguments require less management.


>
> any examples will be appreciated
>
> Thanks
>
>
>
>  --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> 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/d/optout.
>



-- 
Martynas Mickevičius
Typesafe <http://typesafe.com/> – Reactive
<http://www.reactivemanifesto.org/> Apps on the JVM

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      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/d/optout.

Reply via email to