Note that there are some explanatory texts on larger screens.

plurals
  1. POExample of integration Akka with existing java project
    primarykey
    data
    text
    <p>If I already have existing <code>java</code> web application that uses <code>spring</code> and <code>servlet</code> container. What is the proper way to integrate Akka in it? </p> <p>Like I'g going to have <code>Actor1</code> and <code>Actor2</code> that communicate with each other. What would be the entry point to start using those actors? (like: 1. put it there 2. change config 3. get reference to actor)</p> <p>I found <a href="http://doc.akka.io/docs/akka/2.2-M3/general/configuration.html" rel="nofollow noreferrer">http://doc.akka.io/docs/akka/2.2-M3/general/configuration.html</a> But his does not provide me a glue. Just want to get real example of integration.</p> <p>Is there some simple integration example?</p> <p><strong>EDIT:</strong> Application does some search, getting some data from outside, storing info to files.</p> <p>The application is quite big. Some components/object can leave their own life, that is out of direct client requests, it can do some things is parallel. Like some singleton objects that has mutable state in it. </p> <p>The thing is I do not know exactly where I can apply Actors, I'm investigation it. But what I have already is lots of synchronized blocks here and there. </p> <p>And, it is already, I believe, kind of sign that the actors might be applied. <em>(because I'm not sure, maybe I forgot to put some <strong>synchronized</strong>, and of course there are no integration tests for it)</em></p> <p>About configuration, I'm just not sure should I configure some application.conf for let Actrors/Akka live there (<strong>since documentation itself describes it</strong>).</p> <p>What I see: </p> <pre><code>@Component("someManager") public class SomeManager { List&lt;Some&gt; something; // mutable state, that why I use locks here. // methods: add(), delete(), update() } </code></pre> <p>I could make it <code>SomeManagerActor</code></p> <p><code>SomeManager</code> is used from <code>controller</code>. Thus, it would be nice to have controller Actor as well ? I it want to receive feedback into (<code>onReceive</code>() method).</p> <p>This is kind of disputable... That's one more reason why I need some <strong>example</strong>.</p> <p>I believe I can improve application by getting rid of all <code>synchronized/whait/notify</code> stuff, moving responsibilities to actors, using messages as a way of communication with/between them.</p> <p>Or like <a href="https://stackoverflow.com/questions/11576439/parallel-file-processing-in-scala">this</a> it could be the <strong>actor to write to property files</strong>: </p> <p><strong>EDIT:</strong></p> <p>For example, for now what I found: To make Actor1 send message to Actor2 I use a trick:</p> <pre><code>// somewhere in existing code public void initActors() { ActorSystem system = ActorSystem.create(example"); // initializing final ActorRef actor1 = system.actorOf(Props.create(Actor1.class), "actor1"); } </code></pre> <p>Actor1 has a method <code>preStart()</code> that is started as soon as I get reference to it (above). And it sends message to Actor2:</p> <pre><code>@Override public void preStart() { </code></pre> <blockquote> <p>But I'm not sure that it is good why to initialize two actors to do their work.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload