Files
stream-applications/functions/consumer/mongodb-consumer
Chris Bono ec0d8dd227 [SB3 Update] Move MongoDbTestContainerSupport to functions/common
- use in mongodb-consumer
- use in mongodb-supplier
2022-10-16 23:52:42 -05:00
..
2020-08-11 13:08:28 -04:00

# MongoDB Consumer

A consumer that allows you to insert records into MongoDB.

## Beans for injection

You can import `MongoDbConsumerConfiguration` in the application and then inject one of the following beans.

`Function<Message<?>, Mono<Void>> mongodbConsumerFunction` - Allows you to subscribe.

`Consumer<Message<?>> mongodbConsumer` - Wraps the function as a Consumer with no-op subscriber.

You can use `mongodbConsumer` or `mongodbConsumerFunction` as a qualifier when injecting.

The return value from the function can be ignored as this is used as a consumer to send records to MongoDB.

## Configuration Options

All configuration properties are prefixed with `mongodb.consumer`.

For more information on the various options available, please see link:src/main/java/org/springframework/cloud/fn/consumer/mongo/MongoDBConsumerProperties.java[MongoDBConsumerProperties].

## Examples

See this link:src/test/java/org/springframework/cloud/fn/consumer/mongo/MongoDBConsumerApplicationTests.java[test suite] for the various ways, this consumer is used.

## Other usage

See this https://github.com/spring-cloud/stream-applications/blob/master/applications/sink/mongodb-sink/README.adoc[README] where this consumer is used to create a Spring Cloud Stream application where it makes a MongoDB sink.