Thank you very much for your replay .
actually  I am using a sort of scatter gather pattern to fetch data . each
actor should fetch part of data according to param (e.d customer ID) . and
an actor that aggregates the results applying some business logic and
stores the result in the db .

so what is the best practice to achieve that  ? should I send the
repository to each actor constructor  ? or using cake pattern or other
abstraction
  ?

Best
AL




On Fri, Apr 17, 2015 at 4:14 PM Martynas Mickevičius <
[email protected]> wrote:

> Hi,
>
> On Sun, Apr 5, 2015 at 5:10 PM, AL <[email protected]> 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 [email protected].
>
>
>> To post to this group, send email to [email protected].
>> 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 a topic in the
> Google Groups "Akka User List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/akka-user/e75kStFFdVQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
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