On Mon, Apr 18, 2016 at 12:39 PM, Fernando Benjamin <
[email protected]> wrote:

> Hi there,
>
> I am implementing a Kafka Client and I would like to create one instance
> of RunnableGraph (listener) to listen to each Partition and keep the
> references to the runnables for further administration.
> One of the administration tasks is to stop listening to one of the
> partitions.
> 1. How could I possibly stop a RunnableGraph?
>
Materializer.shutdown() or add a killSwitch to your flow and materialize it.



> 2. And how could I handle errors for each RunnableGraph separately in
> order to implement behaviour like stop/restart listening to a certain event?
>
Stop working with RunnableGraph and instead use the combinators provided by
FlowOps for dealing with pipeline failures.
RunnableGraph is like a Runnable—its purpose is not to add things to it,
but to run it.



>
>     val g: RunnableGraph[_] = RunnableGraph.fromGraph(GraphDSL.create() {
> implicit builder =>
>
>      val connFlow: Flow[HttpRequest, HttpResponse, Future[Http.
> OutgoingConnection]] = connection.connection()
>
>
>
>       val out: Outlet[HttpResponse] = builder.add(Source.single(request).
> via(connFlow)).out
>
>       val transform2ByteString: FlowShape[HttpResponse, ByteString] =
> builder.add(null)
>
>       val transform2String: FlowShape[ByteString, String] = builder.add(
> null)
>
>       val deserialize2Object: FlowShape[String, T] = builder.add(null)
>
>       val filterMessagesWithEvents: FlowShape[T, T] = builder.add(null)
>
>       val publishEvent2listener: Inlet[Any] = builder.add(Sink.ignore).in
>
>
>        // Graph
>
>       out ~> transform2ByteString ~> transform2String ~>
>
>        deserialize2Object ~> filterMessagesWithEvents ~>
> publishEvent2listener
>
>             ClosedShape //
>
>     })
>
>     g.run()
>
> Thank you in advance,
>
> Fernando
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Cheers,
√

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to