0

I am trying to setup a stream with Akka's javadsl which handles the processing of new files in a folder. My question is:

Should I re-run the RunnableFlow every time a new file is introduced,

or is it possible to keep a RunnableFlow running indefinitaly while the stream is waiting for new files to be introduced to the Source of said Flow?

My source as it is now:

Queue<Path> esbList = new Queue<>();
final Source<Path, BoxedUnit> pathSource = Source.from(esbList);

The Queue is a simple iterable queue

JHeut
  • 185
  • 2
  • 9
  • This is a potential duplicate of an answer I previously gave on having a dynamic (unbounded) source. Take a look here: http://stackoverflow.com/questions/29072963/how-to-add-elements-to-source-dynamically/29077212#29077212 – cmbaxter May 19 '15 at 14:10
  • I agree, the questions are very much alike. Is your answer to that question also applicable in a javadsl manner? – JHeut May 19 '15 at 14:28
  • The code I wrote there "should" be able to be ported over to java. I think the underlying concept of using an actor as the source should still work though I have not tried it myself. – cmbaxter May 19 '15 at 14:37
  • I'll see if I can port it. If so, i'll close this question, if not, I'd like to keep it open, altered to specify javadsl. Thanks for your input! – JHeut May 19 '15 at 14:38

1 Answers1

0

As it turns out it is not possible to add elements to a Source which has been created from a collection like a queue. The available elements in the collection will be passed during the materialization of the stream and the stream will be completed when these elements are processed.

As cmbaxter mentions creating a Source in which elements can be added after materialization is possible by creating a Source via an ActorPublisher.

Akka documentation:

http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC3/java/stream-integrations.html#ActorPublisher

Related question:

How to add elements to Source dynamically?

Community
  • 1
  • 1
JHeut
  • 185
  • 2
  • 9