java - How to get UpsertResult when using Mongo Outbound channel adapter?
问题描述
I'm using spring integration to store data in a mongo database. I'm using the java classes (MongoDbStoringMessageHandler), not the xml configuration and I can't find the way to get the results when adding some data in the database...
Is it possible ? How ?
解决方案
这MongoDbStoringMessageHandler
是一个单向组件,它不返回任何东西。
考虑使用 aMongoDbOutboundGateway
而不是CollectionCallback
注入的地方,您可以在其中执行 anupdateMany()
并UpdateResult
从该网关获取回复。
在参考手册中查看更多信息:https ://docs.spring.io/spring-integration/reference/html/mongodb.html#mongodb-outbound-gateway
更新
但我不知道要为插入消息有效负载的函数设置什么参数......因为在 ServiceActivator 中没有消息的引用
哦!我懂了。那是一个错误。我们无法从该上下文访问消息。请就此事提出JIRA:https ://jira.spring.io/projects/INT/
同时,作为一种解决方法,我建议您编写一个带有注入的自定义 POJO,MongoOperations
然后您可以针对requestMessage
.
推荐阅读
- docker - Symfony 与 DDEV CLI 数据库连接
- performance - 重新加载时请求阻塞/等待
- python - 给定一个向量和两者之间的角度,找到第二个 n 维向量
- django - CKeditor 无法在 Django 中处理 CreateVIew
- reactjs - 只有一些从 SpaceX API 获取的嵌入式 YouTube 视频不会加载到浏览器中
- python - 使用python将数据流存储在hdf5文件中
- sql-server - SSRS 报告列显示错误的结果
- julia - 使用 Julia GLM 进行分类变量如何选择参考水平?
- git - 使用 vimdiff 解决文件中的 Git 部分合并冲突
- linux - 如何使用存储库中的 APT 安装较旧的 gcc 包?