//package org.egl_cepgl.pm.config;
//
//import org.springframework.data.mongodb.core.CollectionOptions;
//import org.springframework.data.mongodb.core.MongoOperations;
//import org.springframework.stereotype.Service;
//
//@Service
//public class CappedCollectionCreator
//{
//    private final MongoOperations mongoOperations;
//
//    public CappedCollectionCreator(MongoOperations mongoOperations) {
//        this.mongoOperations = mongoOperations;
//    }
//
//    public void createEventCappedCollection() {
//        // Define collection options for a capped collection
//        CollectionOptions cappedOptions = CollectionOptions.empty()
//                .capped()
//                .size(1024 * 1024) // Max size in bytes (e.g., 1MB)
//                .maxDocuments(10000); // Optional: Max number of documents
//
//        // Create the collection if it doesn't exist
//        if (!mongoOperations.collectionExists("chatMessage")) {
//            mongoOperations.createCollection("chatMessage", cappedOptions);
//            System.out.println("Capped 'event' collection created.");
//        } else {
//            System.out.println("Collection 'event' already exists.");
//            // You might want to convert an existing collection to capped if needed,
//            // but this is more complex and involves data migration.
//        }
//    }
//}
