Mongodb 在spring集成中使用mongo入站适配器对数据进行分页

Mongodb 在spring集成中使用mongo入站适配器对数据进行分页,mongodb,spring-integration,Mongodb,Spring Integration,我正在使用mongo入站适配器从mongo检索数据。目前我正在使用以下配置 <int-mongo:inbound-channel-adapter id="mongoInboundAdapter" collection-name="updates_IPMS_PRICING" mongo-template="mongoTemplatePublisher" channel="ipmsPricingUpdateChannelSplitter" que

我正在使用mongo入站适配器从mongo检索数据。目前我正在使用以下配置

<int-mongo:inbound-channel-adapter
        id="mongoInboundAdapter" collection-name="updates_IPMS_PRICING"
        mongo-template="mongoTemplatePublisher" channel="ipmsPricingUpdateChannelSplitter"
        query="{'flagged' : false}" entity-class="com.snapdeal.coms.publisher.bean.PublisherVendorProductUpdate">
        <poller max-messages-per-poll="2" fixed-rate="10000"></poller>
    </int-mongo:inbound-channel-adapter>

我的数据库中大约有20条记录符合上述查询的条件,但由于我给出的每个轮询的最大消息数值为2,我希望每次轮询最多能得到2条记录。
但我得到了所有符合上述查询条件的记录。不确定我做错了什么。

mongo适配器设计用于返回单个消息,其中包含每次轮询的查询结果集合。因此,
max messages per poll
在这里没有区别

max messages per poll
用于使轮询器短路,在您的情况下,第二次轮询将立即完成,而不是再次等待10秒。两次投票后,我们再次等待

为了实现分页,您需要使用
查询表达式
而不是
查询
,并在某个地方维护一些状态,这些状态可以包含在每次轮询的查询中


比如说,,如果文档有一些递增的值,您可以将该值存储在bean中,并在下一次轮询中使用该值来获得下一个值。

实际上,我建议为该
查询表达式提出一个
新特性,以允许指定
org.springframework.data.mongodb.core.query.query
builder,它有
skip()
limit()
选项,从那里可以解决您的问题,如:

<int-mongo:inbound-channel-adapter
    query-expression="new BasicQuery('{\'flagged\' : false}').limit(2)"/>

将为此功能提出jira罚单。