[akka-user] Multiple Akka ask getting same actor reference name.

2016-07-27 Thread Love Hasija
Hi,

I am observing a strange behavior but I am sure, I did something wrong.

I have a service class providing a DB Wrapper, which has async methods for 
providing services. Internally there is an actor workflow. but the service 
class is not part of actor system and simply invokes ask to the actor 
system.

Here's an example.

Async Service => Supervisor => Workers.
(ask)  => (results from the supervisor).

When I am testing the same using Junit by invoking multiple parallel 
requests., what I am observing is that the supervisors and workers behave 
properly, but only the first response comes back to ask actor, others are 
lost to the dead letter queue.

While debugging, I saw all the ask actor references are same: 
Actor[akka://MyActorSystem/temp/$a]

Is it something, I am doing wrong.

-- 
>>  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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Multiple Akka ask getting same actor reference name.

2016-07-27 Thread Love Hasija
Yeah you are right. Actually that's what is happening. I may not have 
explained it right.

The Actor system has a hierarchy of master and multiple workers. The master 
is responsible for correlating the stream of result from the workers, 
correlating, aggregating and returning a single response to the non-actor 
instance.

The non-actor instance here is using ask to get a single response. Where I 
am coming for is, when i use Junit and invoke multiple requests to the 
non-actor instance. I am invoking the actor system individually and 
expecting multiple ask returns. It is something like this.

for(i=0;i<10;i++) {
 non_actor_instance.request();
}

function request() {
 ask(supervisor, msg);
}

On Wednesday, 27 July 2016 21:53:01 UTC+5:30, Justin du coeur wrote:
>
> Hmm -- I think you may be misunderstanding ask.  Ask sends *one* message, 
> and gets *one* response.  It sounds like you're trying to use it to get a 
> stream of responses, and it just doesn't do that.
>
> For that matter, ask gives you back a Future, and Future only returns a 
> single response.  It's not designed to represent a stream.
>
> To get a stream of responses, which sounds like what you're looking for, 
> you're going to have to build something more sophisticated, I'm afraid.  My 
> usual recommendation would be to add another Actor in the workflow, which 
> receives the initial ask, sends out the request, collates the results from 
> the workers and returns them as a *single* response to the non-Actor code...
>
> On Wed, Jul 27, 2016 at 5:17 AM, Love Hasija <love2d...@gmail.com 
> > wrote:
>
>> Hi,
>>
>> I am observing a strange behavior but I am sure, I did something wrong.
>>
>> I have a service class providing a DB Wrapper, which has async methods 
>> for providing services. Internally there is an actor workflow. but the 
>> service class is not part of actor system and simply invokes ask to the 
>> actor system.
>>
>> Here's an example.
>>
>> Async Service => Supervisor => Workers.
>> (ask)  => (results from the supervisor).
>>
>> When I am testing the same using Junit by invoking multiple parallel 
>> requests., what I am observing is that the supervisors and workers behave 
>> properly, but only the first response comes back to ask actor, others are 
>> lost to the dead letter queue.
>>
>> While debugging, I saw all the ask actor references are same: 
>> Actor[akka://MyActorSystem/temp/$a]
>>
>> Is it something, I am doing wrong.
>>
>> -- 
>> >>>>>>>>>> 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+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Multiple Akka ask getting same actor reference name.

2016-07-28 Thread Love Hasija
Thanks for your help Justin.

I explored a little bit more on the Master worker and you were right. The 
problem was that for each ask i was keeping an actor instance level 
reference to the caller, and that's the reason for each ask message, the 
response was directing to a single actor reference, leading to dead letter 
references.

I updated it to have the caller references part of the message envelope.

On Wednesday, 27 July 2016 23:07:56 UTC+5:30, Justin du coeur wrote:
>
> Hmm.  Nothing apparently wrong with that.  You say that messages are 
> dropping into dead letters -- is that the requests or the responses that 
> are being dropped?  If it's the responses, it might be helpful to see the 
> code of the master, which is likely to be the source of the problem...
>
> On Wed, Jul 27, 2016 at 1:20 PM, Love Hasija <love2d...@gmail.com 
> > wrote:
>
>> Yeah you are right. Actually that's what is happening. I may not have 
>> explained it right.
>>
>> The Actor system has a hierarchy of master and multiple workers. The 
>> master is responsible for correlating the stream of result from the 
>> workers, correlating, aggregating and returning a single response to the 
>> non-actor instance.
>>
>> The non-actor instance here is using ask to get a single response. Where 
>> I am coming for is, when i use Junit and invoke multiple requests to the 
>> non-actor instance. I am invoking the actor system individually and 
>> expecting multiple ask returns. It is something like this.
>>
>> for(i=0;i<10;i++) {
>>  non_actor_instance.request();
>> }
>>
>> function request() {
>>  ask(supervisor, msg);
>> }
>>
>> On Wednesday, 27 July 2016 21:53:01 UTC+5:30, Justin du coeur wrote:
>>>
>>> Hmm -- I think you may be misunderstanding ask.  Ask sends *one* 
>>> message, and gets *one* response.  It sounds like you're trying to use it 
>>> to get a stream of responses, and it just doesn't do that.
>>>
>>> For that matter, ask gives you back a Future, and Future only returns a 
>>> single response.  It's not designed to represent a stream.
>>>
>>> To get a stream of responses, which sounds like what you're looking for, 
>>> you're going to have to build something more sophisticated, I'm afraid.  My 
>>> usual recommendation would be to add another Actor in the workflow, which 
>>> receives the initial ask, sends out the request, collates the results from 
>>> the workers and returns them as a *single* response to the non-Actor code...
>>>
>>> On Wed, Jul 27, 2016 at 5:17 AM, Love Hasija <love2d...@gmail.com> 
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am observing a strange behavior but I am sure, I did something wrong.
>>>>
>>>> I have a service class providing a DB Wrapper, which has async methods 
>>>> for providing services. Internally there is an actor workflow. but the 
>>>> service class is not part of actor system and simply invokes ask to the 
>>>> actor system.
>>>>
>>>> Here's an example.
>>>>
>>>> Async Service => Supervisor => Workers.
>>>> (ask)  => (results from the supervisor).
>>>>
>>>> When I am testing the same using Junit by invoking multiple parallel 
>>>> requests., what I am observing is that the supervisors and workers behave 
>>>> properly, but only the first response comes back to ask actor, others are 
>>>> lost to the dead letter queue.
>>>>
>>>> While debugging, I saw all the ask actor references are same: 
>>>> Actor[akka://MyActorSystem/temp/$a]
>>>>
>>>> Is it something, I am doing wrong.
>>>>
>>>> -- 
>>>> >>>>>>>>>> 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+...@googlegroups.com.
>>>> To post to this group, send email to akka...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/akka-user.
>>>> F

[akka-user] Akka Pattern for a Transactional system with multi-hop requests.

2016-07-16 Thread Love Hasija
Hi,

I am working on solving a problem where there is a business service that is 
using HBase as a data layer and we are building secondary indexes on the 
HBase. As you can imagine, a single business service request spawns 
multiple request to the DB layer within a single logical transaction 
boundaries.

Each request to the DB Layer may contain certain state, like the 
acknowledgment of the Index update/save request followed by the update of 
the record/entity in hand.

Since, the DB calls are all asynchronous, I don't see a need to create a 
pool of worker(db clients) for the request/response cycle with the the 
database. Although, I am confused for the right pattern to use.

1) Is Akka at all required or should futures be enough (I feel like each 
request to database may have certain state that comes back, so it would be 
better to use Akka then only futures).
2) Should a parent child hierarchy, parent acting as 
manager/aggregator/collaborator and child acting as the client to the 
database looks good. If yes, how do we make sure an actor instance is 
spawned per request for the master and the worker actor.

Sorry, for the long question as I am a newbie to the Actor System.

-- 
>>  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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka Pattern for a Transactional system with multi-hop requests.

2016-07-16 Thread Love Hasija
Appreciate your help.

This looks great. Would you be able to point me to any possible 
implementation on Akka. I am wondering what would be the right design for 
an Akka implementation in terms of Master/Worker etc.

On Saturday, 16 July 2016 23:37:01 UTC+5:30, Dragisa Krsmanovic wrote:
>
> Looks like that you are trying to do distributed transactions. 
>
> I'd recommend you look into Saga pattern. 
>
> For example, see here 
> http://kellabyte.com/2012/05/30/clarifying-the-saga-pattern/ and here 
> https://speakerdeck.com/caitiem20/applying-the-saga-pattern
>
> On Sat, Jul 16, 2016 at 9:25 AM Love Hasija <love2d...@gmail.com 
> > wrote:
>
>> Hi,
>>
>> I am working on solving a problem where there is a business service that 
>> is using HBase as a data layer and we are building secondary indexes on the 
>> HBase. As you can imagine, a single business service request spawns 
>> multiple request to the DB layer within a single logical transaction 
>> boundaries.
>>
>> Each request to the DB Layer may contain certain state, like the 
>> acknowledgment of the Index update/save request followed by the update of 
>> the record/entity in hand.
>>
>> Since, the DB calls are all asynchronous, I don't see a need to create a 
>> pool of worker(db clients) for the request/response cycle with the the 
>> database. Although, I am confused for the right pattern to use.
>>
>> 1) Is Akka at all required or should futures be enough (I feel like each 
>> request to database may have certain state that comes back, so it would be 
>> better to use Akka then only futures).
>> 2) Should a parent child hierarchy, parent acting as 
>> manager/aggregator/collaborator and child acting as the client to the 
>> database looks good. If yes, how do we make sure an actor instance is 
>> spawned per request for the master and the worker actor.
>>
>> Sorry, for the long question as I am a newbie to the Actor System.
>>
>> -- 
>> >>>>>>>>>> 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+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka design to create repositories.

2016-09-19 Thread Love Hasija
Hi,

I am trying to create a domain driven repository using Akka. However, i am 
confused with regard to what the ideal design should look like.

I have domain objects like Entity and a repository needs to be created with 
various interfaces like findByXYZ() and add().

The requirement for individual repository operations like findByXYZ and add 
are that these operations are multi-step and includes state in them. As an 
example, a pseudo code for findByXYZ would be:

- findByX
- findByY
- findByZ
- Aggregate
- Get the resulting data.

The way i approached this, is by creating a single worker actor that 
triggers a workflow by invoking futures for each of steps defined above and 
invoking respective messages to itself. As all the results are obtained, 
the results are accumulated and returned back.

However, what I am wondering is that:
1) Are future compositions not enough for this, do we really need an 
actor. The advantage I see is alternative corrective path if required.
2) The single actor is performing multiple types of workflows, for eg: 
1 for adding new record, 1 for finding. However, this is creating a big 
actor. Can multiple actors be created for each type of command messages.

Any help would be greatly appreciated.

-- 
>>  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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka design to create repositories.

2016-09-20 Thread Love Hasija
Will appreciate some help

-- 
>>  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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.