【发布时间】:2018-08-03 15:22:17
【问题描述】:
使用 spring 云数据流,我正在尝试使用 Kafka 压缩主题从数据库中复制数据。出于这个原因,我需要在将记录生成到主题(称为 foo)时设置记录的键。
kafka-topics --zookeeper localhost:2181 --create --topic foo --replication-factor=1 --partitions 3 --config cleanup.policy=compact
stream create --name foo --deploy --definition "jdbc --spring.datasource.url=jdbc:postgresql://localhost:5432/chiodonia --spring.datasource.driver-class-name=org.postgresql.Driver --jdbc.max-rows-per-poll=10 --jdbc.query='select id, value from foo where seen is null' --jdbc.split=true --jdbc.update='update foo set seen=current_timestamp where id in (:id)' --trigger.fixed-delay=5 --trigger.time-unit=SECONDS | header-enricher --headers='recordkey=payload.id' > :foo --spring.cloud.stream.kafka.bindings.output.producer.messageKeyExpression=headers['recordkey']"
任何人都可以使用 Spring Cloud 数据流将记录的密钥设置到 kafka 中吗?
【问题讨论】:
标签: apache-kafka key record spring-cloud-dataflow