def startProcessing() = {
readQuery
.eventsByTag(TaggingEventAdapter.driverStateEvent, Offset.noOffset)
.groupedWithin(5, 2.seconds)
.mapAsync(1) { envelopes =>
processEvents(envelopes.map(_.event)).map(_ => envelopes.last.offset).map{
offset => self ! UpdateOffsetCommand(TaggingEventAdapter.driverStateEvent, offset)
}
}
.runWith(Sink.ignore)
}
def processEvents(events: Seq[Any]): Future[Unit] = {
log.info(events.toString())
null
}
当我的代码控制没有到达时
map{offset => self ! UpdateOffsetCommand(TaggingEventAdapter.TestStateEvent, offset)}
位置,
鉴于eventsByTag在向量中获得两个事件。 envelopes
也是事件。但它没有达到第三map
答案 0 :(得分:1)
您的processEvents
方法看起来非常可疑,因为它返回null
。将其更改为以下内容(假设log.info
的返回类型为Unit
):
def processEvents(events: Seq[Any]): Future[Unit] = Future {
log.info(events.toString())
}