Interface MessageCollectionCallback<T>

All Superinterfaces:
org.springframework.data.mongodb.core.CollectionCallback<T>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface
public interface MessageCollectionCallback<T>
extends org.springframework.data.mongodb.core.CollectionCallback<T>
The callback to be used with the MongoDbOutboundGateway as an alternative to other query options on the gateway.

Plays the same role as standard CollectionCallback, but with Message<?> requestMessage context during handleMessage() process in the MongoDbOutboundGateway.

Since:
5.0.11
See Also:
CollectionCallback
  • Method Summary

    Modifier and Type Method Description
    default T doInCollection​(com.mongodb.client.MongoCollection<org.bson.Document> collection)  
    T doInCollection​(com.mongodb.client.MongoCollection<org.bson.Document> collection, org.springframework.messaging.Message<?> requestMessage)
    Perform a Mongo operation in the collection using request message as a context.
  • Method Details

    • doInCollection

      @Nullable T doInCollection​(com.mongodb.client.MongoCollection<org.bson.Document> collection, org.springframework.messaging.Message<?> requestMessage) throws com.mongodb.MongoException, org.springframework.dao.DataAccessException
      Perform a Mongo operation in the collection using request message as a context.
      Parameters:
      collection - never null.
      requestMessage - the request message ot use for operations
      Returns:
      can be null.
      Throws:
      com.mongodb.MongoException - the MongoDB-specific exception
      org.springframework.dao.DataAccessException - the data access exception
    • doInCollection

      default T doInCollection​(com.mongodb.client.MongoCollection<org.bson.Document> collection) throws com.mongodb.MongoException, org.springframework.dao.DataAccessException
      Specified by:
      doInCollection in interface org.springframework.data.mongodb.core.CollectionCallback<T>
      Throws:
      com.mongodb.MongoException
      org.springframework.dao.DataAccessException