消息未发送到 DLQ 主题



我想将DLQ用于异常

这是应用程序.yml 已成功创建主题,但我在 DLQ 主题中没有收到异常消息

spring:
cloud:
stream:
default:
consumer:
useNativeEncoding: true
kafka:
binder:
brokers:
- localhost:9092
consumer-properties:
key.deserializer : org.apache.kafka.common.serialization.StringDeserializer
value.deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
schema.registry.url: http://localhost:8081
specific.avro.reader: true
enable.auto.commit: true
bindings:
resourceInventoryInput:
consumer:
autoCommitOffset: true
autoCommitOnError: true
enableDlq: true
dlqName: dead-out
dlqProducerProperties:
configuration:
key.serializer: org.apache.kafka.common.serialization.StringSerializer
value.serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
bindings:
resourceInventoryInput:
binder: kafka
destination: ${application.messaging.topic}
content-type: application/*+avro
group: ${application.messaging.group}
default-binder: kafka

不要在多个地方问同一个问题;这是浪费你和我们的时间。

我已经在GitHub上回答了你。

我刚刚用 Boot 2.1.15 和 Greenwich.SR6(和 Boot 2.2.8/Hoxton.SR5(测试了你的 yaml,它工作得很好。我所做的唯一更改是将绑定名称更改为输入并注释掉 avro 内容。

@SpringBootApplication
@EnableBinding(Sink.class)
public class Kbgh9181Application {
public static void main(String[] args) {
SpringApplication.run(Kbgh9181Application.class, args);
}
@StreamListener(Sink.INPUT)
public void listen(String in) {
throw new RuntimeException("foo");
}
@KafkaListener(id = "kbgh918", topics = "dead-out", properties = "auto.offset.reset:earliest")
public void listen(Message<?> in) {
System.out.println(in);
}
}

GenericMessage [payload=byte[3], headers={x-original-offset=[B@67917b81, x-original-partition=[B@467895cd, kafka_timestampType=CREATE_TIME, kafka_receivedMessageKey=null, kafka_receivedTopic=dead-out, kafka_offset=5, x-exception-message=[B@51def01e, x-exception-fqcn=[B@531d42e5, kafka_consumer=org.apache.kafka.clients.consumer.KafkaConsumer@3fbc6674, x-original-topic=[B@3d684ab3, x-original-timestamp-type=[B@1b101300, kafka_receivedPartitionId=0, x-original-timestamp=[B@222370ed, kafka_receivedTimestamp=1592402977606, x-exception-stacktrace=[B@7e703d1b}]

相关内容

  • 没有找到相关文章

最新更新