Count Number of Rows Processed by Mule DataMapper

时间:2015-07-28 23:12:07

标签: mule esb mule-studio mule-component

I am using Mule's datamapper to write data from a database to a csv file. I am using the streaming option on the database, the datamapper and the file ouput. I want to be able to log the amount of records written by the datamapper. Is there a way to get this data? I am running mule server 3.5.2 and have anypoint studio version 5.2.0.

2 个答案:

答案 0 :(得分:1)

没有开箱即用。如果您不使用流式传输,则可以使用outputArgument并增加计数器。

如果您正在使用流式传输,则可以传递计数器类的输入参数。从Datamapper的脚本组件中,您可以递增计数器并将计数器作为有效负载的一部分返回以访问它:

        <data-mapper:transform config-ref="Pojo_To_JSON_1" doc:name="Pojo To JSON" stream="true">
            <data-mapper:input-arguments>
                <data-mapper:input-argument key="counter">#[new Counter()]</data-mapper:input-argument>
            </data-mapper:input-arguments>
        </data-mapper:transform>

Datamapper脚本:

//MEL
//START -> DO NOT REMOVE
output.__id = input.__id;
//END -> DO NOT REMOVE

output.text = inputArguments.counter.increment();

答案 1 :(得分:1)

我知道这是一个旧帖子,但仍然可以提供帮助 -

 <byte-array-to-object-transformer doc:name="Byte Array to Object"/>
 <set-variable variableName="Orig_Rows" value="#[payload.length]" doc:name="Variable"/>