0
を通して私は、次のコードスニペットがあります。私は、フローにメッセージを送信していたコードでアッカストリーム+アッカのHttpパスパラメータフロー
case class SomeClass(param1:String,param2:String,param3:String)
val someClassActorSource: Source[SomeClass, ActorRef] = Source
.actorPublisher[SomeClass](Props[SomeClassActorPublisher])
val someFlow: ActorRef = Flow[SomeClass]
.mapAsync(3)(f=> getDocumentById(f))
.map(f =>{
val request = HttpRequest(method = HttpMethods.POST, uri = "http://localhost:8000/test")
.withEntity(ContentTypes.`text/xml(UTF-8)`, ByteString(f.a)
)
(request,request)
}).via(connection)
//Parsing Response
.mapAsync(3){
case (Success(HttpResponse(status, _, entity, _)),request)=>
entity.dataBytes.runFold(ByteString(""))(_ ++ _)
}
.map(resp =>parse(resp.utf8String,?????????????))
.to(Sink.someSink{....})
.runWith(someClassActorSource)
def parse(resp:String,parseParam:String)=????
とどこか:
someflow ! SomeClass("a","b","c")
someflow ! SomeClass("a1","b1","c1")
を私の問題はありますその方法の解析は、それがあるべきである
したがって、最初のメッセージの元のケースクラスからPARAM2使用すべき
parse(response,"b")
と第二のメッセージのためには、そこで問題は、私は流れに提出メソッドからパラメータを取得することができますどのように、ある
parse(response,"b1")
すべきですか?あなたのconnection
値はあなたが接続をタプルにし、代わりに、単にあなたが入力されSomeClass
に渡すことができタプルで二回request
を渡すので取るという事実を使用することができます
val connection = Http().cachedHostConnectionPool(...)
を経由してインスタンス化されると仮定すると、