4

我正在尝试使用属性 header.CamelSqlRowCount 打印 sql 组件选择的行数。然而,价值是空的。如另一篇文章中所述,我添加了跟踪以检查标头值,并且仅打印了 breadcrumbId。谁能告诉我我做错了什么?

骆驼路线

        <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}]

骆驼版 - 2.15.1

4

1 回答 1

6

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

于 2017-11-17T14:43:07.397 回答