INT-4196: MongoOutGateway: add CollectionCallback
JIRA: https://jira.spring.io/browse/INT-4196 Add `CollectionCallback` option to the `MongoDbOutboundGateway` Add XML support to CollectionCallback Fix PR comments Fix issue with javadoc parsing * Polishing code style, JavaDocs and some Docs
This commit is contained in:
committed by
Artem Bilan
parent
d973295631
commit
739ebb744b
@@ -318,6 +318,8 @@ The Message payload and headers can be used to specify the query, as well as col
|
||||
If this attribute is not provided the default value is `org.bson.Document`;
|
||||
* `query` or `query-expression` - specifies the MongoDb query.
|
||||
Please refer to http://www.mongodb.org/display/DOCS/Querying[MongoDB documentation] for more query samples.
|
||||
* `collection-callback` - reference to an instance of `org.springframework.data.mongodb.core.CollectionCallback`
|
||||
(NOTE: you can not have both collection-callback and any of the query attributes).
|
||||
|
||||
==== Configuring with Java Configuration
|
||||
|
||||
@@ -337,16 +339,6 @@ public class MongoDbJavaApplication {
|
||||
@Autowired
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
|
||||
@Bean
|
||||
public MessageChannel requestChannel() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageChannel replyChannel() {
|
||||
return new QueueChannel(5);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ServiceActivator(inputChannel = "requestChannel")
|
||||
public MessageHandler mongoDbOutboundGateway() {
|
||||
@@ -356,7 +348,6 @@ public class MongoDbJavaApplication {
|
||||
gateway.setExpectSingleResult(true);
|
||||
gateway.setEntityClass(Person.class);
|
||||
gateway.setOutputChannelName("replyChannel");
|
||||
|
||||
return gateway;
|
||||
}
|
||||
|
||||
@@ -406,4 +397,17 @@ public class MongoDbJavaApplication {
|
||||
}
|
||||
|
||||
}
|
||||
----
|
||||
|
||||
Alternatively to the `query` and `query-expression` properties, you can specify other database operations through
|
||||
the `collectionCallback` property.
|
||||
The following example specifies a count operation:
|
||||
|
||||
[source, java]
|
||||
----
|
||||
private MongoDbOutboundGatewaySpec collectionCallbackOutboundGateway() {
|
||||
return MongoDb.outboundGateway(this.mongoDbFactory, this.mongoConverter)
|
||||
.collectionCallback(MongoCollection::count)
|
||||
.collectionName("foo");
|
||||
}
|
||||
----
|
||||
Reference in New Issue
Block a user