fix(processing): 收紧消息生命周期与投递约束
This commit is contained in:
@@ -79,7 +79,7 @@ class Dispatcher(
|
||||
}
|
||||
|
||||
private fun flushDue(): Boolean =
|
||||
lastFlush?.let { Duration.between(it, scheduler.now()) >= props.schd.flushPeriod } ?: false
|
||||
lastFlush?.let { Duration.between(it, scheduler.now()) >= props.schd.flushPeriod } ?: true
|
||||
|
||||
private fun deliver(target: String, e: MsgEvent) {
|
||||
try {
|
||||
@@ -95,7 +95,7 @@ class Dispatcher(
|
||||
/** 批量发 KAFKA_SCHD:每个 FLID 只发版本号最新的那条未发事件,删除通知发空 value。 */
|
||||
internal fun flushSchd() {
|
||||
val batch = try {
|
||||
msgEvents.mergePendingSchd(props.schd.flushLimit)
|
||||
msgEvents.mergePendingSchd(scheduler.now(), props.schd.flushLimit)
|
||||
} catch (e: Exception) {
|
||||
log.warn("mergePendingSchd failed: {}", e.message)
|
||||
return
|
||||
@@ -121,7 +121,7 @@ class Dispatcher(
|
||||
val sentVersions = batch.associate { it.partitionKey to it.stateVersion }
|
||||
runCatching {
|
||||
while (true) {
|
||||
val superseded = msgEvents.mergePendingSchd(props.schd.flushLimit)
|
||||
val superseded = msgEvents.mergePendingSchd(scheduler.now(), props.schd.flushLimit)
|
||||
.filter { sentVersions[it.partitionKey]?.let { v -> it.stateVersion < v } == true }
|
||||
if (superseded.isEmpty()) break
|
||||
msgEvents.markAllSent(superseded.mapNotNull { it.eventId })
|
||||
|
||||
Reference in New Issue
Block a user