Is this in Atlas? If so and these messages are in JSON you can utilize Atlas Stream Processing to connect to Kafka and write them into your MongoDB Atlas Cluster.