我正在尝试使用属性header.CamelSqlRowCount打印sql组件选择的行数。然而,这个价值是空的。 我在另一篇文章中添加了跟踪以检查标题值,并且只打印了breadcrumbId。谁能告诉我,如果我做错了什么?
骆驼路线
<endpoint id="sqlComponent" uri="sql:${sql.pollerQuery}?dataSource=DataSource&consumer.delay=60000&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}]
骆驼版 - 2.15.1
答案 0 :(得分:4)
此标头未在消费者上设置,仅在生产者上设置。您具有邮件正文列表大小的大小。您可以在Apache Camel上记录JIRA票证,以要求消费者也包含此标题。