feat(delivery): 真实 Kafka 投递端口 + 闭合 G-BACKFILL-BACKOFF 配置缺口
- 新增 KafkaDeliveryPort:ProducerRegistry + 同步 Future.get() 至少一次投递, 闭合 OPS-1 真实适配器要求与 US-07 INV-10/C-29 - 回填退避从硬编码 30s/15min 提升为 backfill-backoff-ms / backfill-backoff-cap-ms 配置绑定,闭合 [G-BACKFILL-BACKOFF] - 删除死依赖 micronaut-redis-lettuce(代码零引用,ACM2-28 Redis 已退出阶段 A)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.gzzn.omms.msgexchange.infra.kafka
|
||||
|
||||
import com.gzzn.omms.msgexchange.delivery.DeliveryPort
|
||||
import io.micronaut.configuration.kafka.ProducerRegistry
|
||||
import io.micronaut.context.annotation.Requires
|
||||
import io.micronaut.core.type.Argument
|
||||
import jakarta.inject.Singleton
|
||||
import org.apache.kafka.clients.producer.Producer
|
||||
import org.apache.kafka.clients.producer.ProducerRecord
|
||||
|
||||
/**
|
||||
* Kafka 真实投递端口:通过 [ProducerRegistry] 拿 default 生产者,D3 参数
|
||||
* (acks=all / enable-idempotence=true / max-in-flight=1)由 `KafkaD3Check` 启动自检。
|
||||
*
|
||||
* 发送同步等 broker 确认(`Future.get()`),语义是至少一次——满足 INV-10 / C-29。
|
||||
* 仅在 `msgx.stubs != true` 时装配;stub 模式走 `StubDeliveryPort`。
|
||||
*/
|
||||
@Requires(property = "msgx.stubs", notEquals = "true")
|
||||
@Singleton
|
||||
class KafkaDeliveryPort(
|
||||
private val registry: ProducerRegistry,
|
||||
) : DeliveryPort {
|
||||
|
||||
private val producer: Producer<String, String> by lazy {
|
||||
registry.getProducer("default", Argument.of(String::class.java), Argument.of(String::class.java))
|
||||
}
|
||||
|
||||
override fun sendKafka(topic: String, key: String, payloadJson: String) {
|
||||
producer.send(ProducerRecord(topic, key, payloadJson)).get()
|
||||
}
|
||||
|
||||
override fun sendKafkaSchd(topic: String, key: String, payloadJson: String) {
|
||||
producer.send(ProducerRecord(topic, key, payloadJson)).get()
|
||||
}
|
||||
|
||||
override fun sendKafkaNull(topic: String, key: String) {
|
||||
producer.send(ProducerRecord<String, String>(topic, key, null)).get()
|
||||
}
|
||||
|
||||
override fun ping(): Boolean = try {
|
||||
producer.partitionsFor("msg")
|
||||
true
|
||||
} catch (_: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user