I'm using an ActorPublisher
as an Akka-Stream Source
. I can't figure out how to predictably name the input actor so I can send it messages from other parts of my application. I'm instantiating my source like so:
val src = Source[Task](Props(classOf[TaskListener], this), "task-listener")
I get an ActorRef
when I materialize the stream, but the path for it is dynamically generated, and it only uses my provided name as part of a code-generated flow-centric naming scheme.
Is there any way to have this front-end actor source have an explicit name or am I stuck passing the ActorRef around?
If I can't explicitly name it does this mean you can't use Akka-Stream directly with remoting?
EDIT: I can find my actor using relative pathing now, but I still need to figure out how to name my Flow
so I can understand what the full path to the actor in question will be.
EDIT: (akka version info below, scala 2.11.6)
"com.typesafe.akka" %% "akka-actor" % "2.3.9"
"com.typesafe.akka" %% "akka-stream-experimental" % "1.0-M4"
EDIT: The friendly folks over at the akka-user google group have enlightened me, and suggest that the proper way to deal with this is by passing around the ActorRef
that results from the runWith()
call itself and not using .actorSelection()
. I will update this question if I find that this state of affairs changes in the future. Thanks for reading.
java.io.Serializable. An ActorRef is the identity or address of an Actor instance. It is valid only during the Actor’s lifetime and allows messages to be sent to that Actor instance.
Unlike heavier “streaming data processing” frameworks, Akka Streams are neither “deployed” nor automatically distributed.
The Akka Streams library calls them materialized values. That's because, when you plug components together, you have an inert graph, but when you call the run method, the graph comes alive, or is materialized. The Jedi value returned by materializing a graph is called a materialized value.
Akka Streams is a library to process and transfer a sequence of elements using bounded buffer space. This latter property is what we refer to as boundedness, and it is the defining feature of Akka Streams.
Good way to solve this, will be adding Group router with specific path, then you can tell router where it can find you actors (routees).
By doing this you will decouple your concrete actor group and maintain single point of entry to your Source pool via router. Also you will be able to make this router cluster aware in future.
You can also look into ActorFlowMaterializer - http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M5/index.html#akka.stream.ActorFlowMaterializer itself. You can find this comment in source code:
/** The `namePrefix` is used as the first part of the names of the actors running
* the processing steps. The default `namePrefix` is `"flow"`. The actor names are built up of
* `namePrefix-flowNumber-flowStepNumber-stepName`.
*/
def create(settings: ActorFlowMaterializerSettings, context: ActorRefFactory, namePrefix: String): ActorFlowMaterializer =
apply(Option(settings), Option(namePrefix))(context)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With