Examples for using Akka Http in streaming fashion?

334 views
Skip to first unread message

Harry

unread,
Oct 16, 2017, 11:49:31 AM10/16/17
to Akka User List
Hi,

I have been learning Akka Streams lately in a bid to use it to build a utility to handle a batch scenario I have.
I have been looking also at Akka Http also but have become a bit blocked because although the documentation is quite extensive there are not many examples.

My use case is this:-

1. Source - Read a file of records (about 500k)
2. Flow - For each record, do a HTTP POST to a remote endpoint
3. Sink - For each Response, just log the outcome (success or failure)

So I have something like this at high-level:-

Source[ByteString, Future[IOResult]]  ->  Flow  ->  Sink[HttpRequest, Future[IOResult]]

I am not looking for someone to write my code for me but I am struggling with putting togethor the whole flow because there are not many 
examples of using the Flows that you can construct in Akka Http.

Since I only need to hit 1 endpoint, I was thinking that the [Flow](https://doc.akka.io/docs/akka-http/current/scala/http/client-side/request-level.html#flow-based-variant) 
based variant of the Akka Http Request-Level Client-Side API would be the way to go, I just need some examples to help me get started. 

Can anyone point me in the right direction of some examples of using ither the Request Level or Host Level APIs for using Akka HTTP in a streaming fashion?

Specifically, Im looking for examples of using Sources and Sinks with the following Flows:-

val hostPoolFlow = Http().cachedHostConnectionPool()
val requestPoolFlow
= Http().superPool()

j...@blackfynn.com

unread,
Nov 13, 2017, 2:19:39 PM11/13/17
to Akka User List
A little late to the party, but here's an example program that does several kinds of streaming using akka-http:


Including:
1. streaming sourced http response
2. streamed response based on a streamed http request
3. a websocket flow
4. simple static response
Reply all
Reply to author
Forward
0 new messages