Merge branch 'master' of github.com:jboner/akka
This commit is contained in:
commit
b924647c30
5 changed files with 38 additions and 27 deletions
|
|
@ -1,8 +1,5 @@
|
|||
package sample.camel;
|
||||
|
||||
import org.apache.camel.Body;
|
||||
import org.apache.camel.Header;
|
||||
|
||||
import se.scalablesolutions.akka.actor.TypedActor;
|
||||
|
||||
/**
|
||||
|
|
@ -10,7 +7,7 @@ import se.scalablesolutions.akka.actor.TypedActor;
|
|||
*/
|
||||
public class RemoteTypedConsumer1Impl extends TypedActor implements RemoteTypedConsumer1 {
|
||||
|
||||
public String foo(@Body String body, @Header("name") String header) {
|
||||
public String foo(String body, String header) {
|
||||
return String.format("remote1: body=%s header=%s", body, header);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package sample.camel;
|
||||
|
||||
import org.apache.camel.Body;
|
||||
import org.apache.camel.Header;
|
||||
import se.scalablesolutions.akka.camel.consume;
|
||||
|
||||
/**
|
||||
* @author Martin Krasser
|
||||
*/
|
||||
public interface RemoteTypedConsumer2 {
|
||||
|
||||
@consume("jetty:http://localhost:6644/camel/remote-typed-actor-2")
|
||||
public String foo(@Body String body, @Header("name") String header);
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +1,13 @@
|
|||
package sample.camel;
|
||||
|
||||
import org.apache.camel.Body;
|
||||
import org.apache.camel.Header;
|
||||
import se.scalablesolutions.akka.camel.consume;
|
||||
import se.scalablesolutions.akka.actor.TypedActor;
|
||||
|
||||
/**
|
||||
* @author Martin Krasser
|
||||
*/
|
||||
public class RemoteTypedConsumer2Impl {
|
||||
public class RemoteTypedConsumer2Impl extends TypedActor implements RemoteTypedConsumer2 {
|
||||
|
||||
@consume("jetty:http://localhost:6644/camel/remote-typed-actor-2")
|
||||
public String foo(@Body String body, @Header("name") String header) {
|
||||
public String foo(String body, String header) {
|
||||
return String.format("remote2: body=%s header=%s", body, header);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package sample.camel
|
||||
|
||||
import se.scalablesolutions.akka.actor.Actor._
|
||||
import se.scalablesolutions.akka.actor.{TypedActor, Actor, ActorRef}
|
||||
import se.scalablesolutions.akka.actor.TypedActor
|
||||
import se.scalablesolutions.akka.camel.Message
|
||||
import se.scalablesolutions.akka.remote.RemoteClient
|
||||
|
||||
|
|
@ -10,22 +10,20 @@ import se.scalablesolutions.akka.remote.RemoteClient
|
|||
*/
|
||||
object ClientApplication extends Application {
|
||||
|
||||
//
|
||||
// TODO: completion of example
|
||||
//
|
||||
|
||||
val actor1 = actorOf[RemoteActor1]
|
||||
val actor1 = actorOf[RemoteActor1].start
|
||||
val actor2 = RemoteClient.actorFor("remote2", "localhost", 7777)
|
||||
|
||||
val actobj1 = TypedActor.newRemoteInstance(
|
||||
classOf[RemoteTypedConsumer1], classOf[RemoteTypedConsumer1Impl], "localhost", 7777)
|
||||
//val actobj2 = TODO: create reference to server-managed typed actor (RemoteTypedConsumer2Impl)
|
||||
val typedActor1 = TypedActor.newRemoteInstance(
|
||||
classOf[RemoteTypedConsumer1],
|
||||
classOf[RemoteTypedConsumer1Impl], "localhost", 7777)
|
||||
|
||||
actor1.start
|
||||
val typedActor2 = RemoteClient.typedActorFor(
|
||||
classOf[RemoteTypedConsumer2], "remote3", "localhost", 7777)
|
||||
|
||||
println(actor1 !! Message("actor1")) // activates and publishes actor remotely
|
||||
println(actor2 !! Message("actor2")) // actor already activated and published remotely
|
||||
|
||||
println(actobj1.foo("x", "y")) // activates and publishes typed actor methods remotely
|
||||
// ...
|
||||
println(typedActor1.foo("x1", "y1")) // activates and publishes typed actor methods remotely
|
||||
println(typedActor2.foo("x2", "y2")) // typed actor methods already activated and published remotely
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package sample.camel
|
|||
import se.scalablesolutions.akka.actor.Actor._
|
||||
import se.scalablesolutions.akka.remote.RemoteNode
|
||||
import se.scalablesolutions.akka.camel.CamelServiceManager
|
||||
import se.scalablesolutions.akka.actor.TypedActor
|
||||
|
||||
/**
|
||||
* @author Martin Krasser
|
||||
|
|
@ -10,11 +11,14 @@ import se.scalablesolutions.akka.camel.CamelServiceManager
|
|||
object ServerApplication extends Application {
|
||||
import CamelServiceManager._
|
||||
|
||||
//
|
||||
// TODO: completion of example
|
||||
//
|
||||
|
||||
startCamelService
|
||||
|
||||
val ua = actorOf[RemoteActor2].start
|
||||
val ta = TypedActor.newInstance(
|
||||
classOf[RemoteTypedConsumer2],
|
||||
classOf[RemoteTypedConsumer2Impl], 2000)
|
||||
|
||||
RemoteNode.start("localhost", 7777)
|
||||
RemoteNode.register("remote2", actorOf[RemoteActor2].start)
|
||||
RemoteNode.register("remote2", ua)
|
||||
RemoteNode.registerTypedActor("remote3", ta)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue