I'm currently in the process of making a pretty large Akka based Java application and I'm running into a couple issues that bug me to no end.
My current package layout looks kinda like this:
My Mobile
class serving as the supervisor of the actors inside the actors
package.
Since I don't want to create a new set of Actors for every HttpClient
and Account
, I pass those around in message objects, which are stored in the messages package, together with the endpoint ActorRef
that receives the final result. This does however create a very cluttered messages
package with a different message for each actor. Eg. MobileForActor1
, Actor1ForMobile
, MobileForActor2
etc. Now my question is, is there a Convention to use for this sort of stuff that deals with this problem and is my structure (Mobile
->Actor1
->Mobile
->Actor2
->etc.) the way Akka wants it to be or do I have to just sort of waterfall the messages (Mobile
->Actor1
->Actor2
->etc.)?
Right now I'm sending a ConnectMessage
to my Mobile
actor which then sends it to Actor1
, Actor1
processes it and sends a new message back to Mobile
, Mobile
sends that response then to Actor2
and the cycle continues with a new message being created based on the old message. Eg. new Message2(message1.foo, message1.bar, message1.baz, newComputatedResult, newComputatedResult2, etc);
Is this good practice or should I include the old instance (which may contain info that isn't useful anymore) and include the new stuff? Eg. new Message2(message1, newComputatedResult, newComputatedResult2, etc);
Or should I do something completely different?
I thought about using TypedActors but those require the use of a waterfall pattern and I don't know how I would pass on the ActorRef of the listener that wants to receive the final result.
I hope I made myself understandable enough because English is not my maiden languages and that the question is clear to everyone.
I'm a beginning Akka developer and love the idea but since the documentation doesn't cover this very well, I figured this would be the best place to ask. Thanks for reading!