How to limit the number of results


By default, there is no constraint on the result size of queries, nonetheless, it is possible to limit the result size by adding a parameter maxRowCount in the URI of the query:
Result limit entry
<to uri="tnd-query:GetPaymentsFilteredByCreationTime?maxRowCount=10"/>

Using the above URI, the result will be limited to 10 rows.

Example

As a reminder, the following example shows how this value would be used in a route.

Route with result limit
<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
    <route>
        <from uri="timer:foo?repeatCount=1"/>
        <!-- Parameter map for query-->
        <setProperty propertyName="tnd-query.parameters">
            <u:map-create>
                <u:map-entry key="tnd-query.referenceTime">
                    <constant>NOW</constant>
                </u:map-entry>
                <u:map-entry key="intersectsInterval"> <!-- alias of the parameter created in the data query -->
                    <!-- chosen function "INTERSECTS" neeeds an interval as input. We build it using the dedicated Camel Utility Expression -->   
                    <u:interval-create> 
                        <u:begin><simple>2015-01-07T10:00:00</simple></u:begin>
                        <u:end><constant>NOW</constant></u:end>
                    </u:interval-create>
                </u:map-entry>
            </u:map-create>
        </setProperty>
        <to uri="tnd-query:GetPaymentsFilteredByCreationTime?maxRowCount=10"/>
        <log message="${body}"/>
    </route>
</routes>

Related Links