我有来自Message队列的Akka流源,例如RabbitMq。对于我想要执行http请求的每条消息,将http请求映射到一个对象并继续向下。
这可以通过使用来自akka http(Http(。。outgoingConnection)的流来实现,还是应该在map操作中执行?
答案 0 :(得分:3)
这正是Http().outgoingConnection
用于(如问题中所述):
type MQMessage = ???
val messageToRequest : (MQMessage) => HttpRequest = ???
type ObjectType = ???
val responseToObjectType = (HttpResponse) => ObjectType = ???
val httpHost : String = ???
val messageFlow : Flow[MQMessage, ObjectType, _] =
Flow.map(messageToRequest)
.via(Http().outgoingConnection(httpHost))
.map(responseToObjectType)