2
我需要使用Spring集成查询到MongoDB的数据,我可以能够查询从MongoDB的,但同样的数据数据返回不止一次相同的数据,Spring集成 - MongoDB的入站通道读取
<bean id="mongoDBFactory"
class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
<constructor-arg name="mongo">
<bean class="com.mongodb.Mongo">
<constructor-arg name="host" value="localhost" />
<constructor-arg name="port" value="27017" />
</bean>
</constructor-arg>
<constructor-arg name="databaseName" value="test" />
</bean>
<int:channel id="controlChannel"/>
<int:control-bus input-channel="controlChannel"/>
<int-mongodb:inbound-channel-adapter
id="mongoInboundAdapter" channel="splittingChannel" auto-startup= "false"
query="{_id:1}"
collection-name="order"
mongodb-factory="mongoDBFactory">
<int:poller fixed-rate="10000" max-messages-per-poll="1000"/>
</int-mongodb:inbound-channel-adapter>
<int:splitter input-channel="splittingChannel" output-channel="logger"/>
<int:logging-channel-adapter id="logger" level="WARN"/>
我正在使用控制通道来启动和停止, 请帮助我如何在查询完成后停止入站通道适配器。
在此先感谢
我不需要删除或修改数据库中的文档,我只想读取与查询匹配的所有文档@Artem Bilan – Vigneshwaran
好吧,好的。考虑使用'':https://docs.spring.io/spring-integration/docs/5.0.0.M6/reference/html/mongodb.html#mongodb-outbound-网关。或者直接使用'MongoTemplate'。但是,您可以使用相同的事务同步方法停止轮询Channel Adapter –