我想限制从MongoDB获取的记录数 这是用于获取匹配条件记录的入站通道适配器 从DB: 我的用例是需要限制获取的记录数量。 假设我有100条符合条件的记录,但我只希望提取10条记录。有谁能帮我实现这个功能吗。

我想限制从MongoDB获取的记录数 这是用于获取匹配条件记录的入站通道适配器 从DB: 我的用例是需要限制获取的记录数量。 假设我有100条符合条件的记录,但我只希望提取10条记录。有谁能帮我实现这个功能吗。,mongodb,mongodb-query,spring-integration,Mongodb,Mongodb Query,Spring Integration,我甚至试过用这个exmaple,但仍然没有一张唱片被拿到这里。有人真的能帮上忙吗 This is the inbound channel adapter which fetches the matching criteria records from the DB: <!-- language: lang-xml --> <int-mongodb:inbound-channel-adapter id="simpleInboundAdapter" chan

我甚至试过用这个exmaple,但仍然没有一张唱片被拿到这里。有人真的能帮上忙吗

This is the inbound channel adapter which fetches the matching criteria records
from the DB:

<!-- language: lang-xml -->

    <int-mongodb:inbound-channel-adapter
      id="simpleInboundAdapter" channel="pollingInputChannel"
      query="{$or:[{'status':'New'},{$and:[{'status':'Failure'},{'noOfRetries':{$lt:3}}]}]}"
      collection-name="custommessages" entity-class="com.att.ssp.deviceeventprocessor.model.CustomMessage"
      mongodb-factory="mongoDbFactory">
        <int:poller fixed-rate="30000" max-messages-per-poll="1">
            <!-- <int:transactional synchronization-factory="txSyncFactory" /> -->
        </int:poller>
    </int-mongodb:inbound-channel-adapter>


My use case is that I need to restrict the number of records fetched.  
Say I have 100 records matching the criteria but I want only 10 records to be fetched. Can any one help me how to achieve that functionality here.

这是从mongo入站适配器筛选Reocrds的错误方法吗。。
或者什么是过滤记录计数的理想方法。

由于
$limit
的一部分,由于
使用$limit运算符,Hi felix感谢您的回复,我在哪里可以使用$limit..您能建议一下吗,我是spring Integration的新手。@felix你应该以answerHi$limit Operator的身份发布。Hi felix感谢你的回复,我在哪里可以使用$limit。@felix你可以建议,作为spring Integration的新手。@felix你应该以answerHi Artem的身份发布,我已经厌倦了这种方法,但它仍然不起作用。好的!使用特定信息和执行结果更新您的问题。抱歉,Artem,您发布的语法对spring integration jar 4.3.8运行良好。因此,我使用的是旧版本的spring integration jar,因为它不起作用。谢谢您发布…)嗨,Artem,我厌倦了这种方法,但仍然不起作用。好的!使用特定信息和执行结果更新您的问题。抱歉,Artem您发布的语法对于spring integration jar 4.3.8运行良好。因此,我使用的是旧版本的spring integration jar,因为它不起作用。谢谢您发布……)
<int-mongodb:inbound-channel-adapter
        id="simpleInboundAdapter" channel="pollingInputChannel"
        query-expression="new BasicQuery('{''status'' : ''New''}').limit(2)"
        collection-name="custommessages" entity-class="com.att.ssp.deviceeventprocessor.model.CustomMessage"
        mongodb-factory="mongoDbFactory">
        <int:poller fixed-rate="30000" max-messages-per-poll="1">
            <!-- <int:transactional synchronization-factory="txSyncFactory" /> -->
            </int:poller>
    </int-mongodb:inbound-channel-adapter>
query-expression="new BasicQuery('{$or:[{''status'':''New''},{$and:[{''status'':''Failure''},{''noOfRetries'':{$lt:3}}]}]}').limit(100)"