gpt4 book ai didi

apache-camel - Apache Camel 如何从 sql 组件访问 Header 值

转载 作者:行者123 更新时间:2023-12-04 03:03:08 25 4
gpt4 key购买 nike

我正在尝试使用属性 header.CamelSqlRowCount 打印由 sql 组件选择的行数。但是,该值即将为空。
我添加了另一篇文章中提到的跟踪来检查标题值,并且只打印了breadcrumbId。谁能告诉我我是否做错了什么?

Camel 路线

        <endpoint id="sqlComponent" uri="sql:${sql.pollerQuery}?dataSource=DataSource&amp;consumer.delay=60000&amp;consumer.useIterator=false"/>
<route id="root">
<from ref="sqlComponent"/>
<log message="Received ${header.CamelSqlRowCount} records from the poller query"/>
<log message="Message Body= ${body}"/>
</route>

记录的跟踪如下
DEBUG 2017-11-16 18:01:00 [Camel (camel-1) thread #0 - sql://SELECT%20ID%20FROM%20TABLE%20WHERE%20PUBLISHED%20=%20'N'] Executing query: SELECT ID FROM TABLE WHERE PUBLISHED = 'N'
INFO 2017-11-16 18:01:01 [Camel (camel-1) thread #0 - sql://SELECT%20ID%20FROM%20TABLE%20WHERE%20PUBLISHED%20=%20'N'] ID-MyMachine >>> (root) from(sql://SELECT%20ID%20FROM%20TABLE%20WHERE%20PUBLISHED%20=%20'N'?consumer.delay=60000&consumer.useIterator=false&dataSource=odsDataSource) --> log[Received ${header.CamelSqlRowCount} records from the poller query] <<< Pattern:InOnly, Headers:{breadcrumbId=ID-MyMachine}, BodyType:java.util.ArrayList, Body:[{ID=1}, {ID=2}, {ID=3}, {ID=4}, {ID=5}]
INFO 2017-11-16 18:01:01 [Camel (camel-1) thread #0 - sql://SELECT%20ID%20FROM%20TABLE%20WHERE%20PUBLISHED%20=%20'N'] Received records from the poller query
INFO 2017-11-16 18:01:01 [Camel (camel-1) thread #0 - sql://SELECT%20ID%20FROM%20TABLE%20WHERE%20PUBLISHED%20=%20'N'] ID-BLRKEC381989D-52624-1510835442422-0-2 >>> (root) log[Received ${header.CamelSqlRowCount} records from the poller query] --> log[Message Body= ${body}] <<< Pattern:InOnly, Headers:{breadcrumbId=ID-MyMachine}, BodyType:java.util.ArrayList, Body:[{ID=1}, {ID=2}, {ID=3}, {ID=4}, {ID=5}]
INFO 2017-11-16 18:01:01 [Camel (camel-1) thread #0 - sql://SELECT%20ID%20FROM%20TABLE%20WHERE%20PUBLISHED%20=%20'N'] Message Body= [{ID=1}, {ID=2}, {ID=3}, {ID=4}, {ID=5}]

Camel 版本 - 2.15.1

最佳答案

此 header 未在消费者上设置,仅在生产者上设置。您有消息正文列表大小的大小。您可以在 Apache Camel 上记录 JIRA 票证,以要求消费者也包含此 header 。

关于apache-camel - Apache Camel 如何从 sql 组件访问 Header 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47347267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com