{"id":44556391,"url":"https://github.com/gaurigshankar/spring-cosmos-change-feed-mongo-api","last_synced_at":"2026-02-13T21:45:28.698Z","repository":{"id":42555499,"uuid":"261637240","full_name":"gaurigshankar/spring-cosmos-change-feed-mongo-api","owner":"gaurigshankar","description":"Demo App CosmosDB ChangeFeed / MongoDB ChangeStream","archived":false,"fork":false,"pushed_at":"2022-03-31T19:07:48.000Z","size":18,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-28T21:44:33.849Z","etag":null,"topics":["changefeed","changestreams","cosmosdb","java","mongodb","reactive-programming","spring-boot","spring-reactive"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaurigshankar.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-06T02:57:23.000Z","updated_at":"2022-08-29T23:55:52.000Z","dependencies_parsed_at":"2022-09-21T20:41:01.064Z","dependency_job_id":null,"html_url":"https://github.com/gaurigshankar/spring-cosmos-change-feed-mongo-api","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/gaurigshankar/spring-cosmos-change-feed-mongo-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurigshankar%2Fspring-cosmos-change-feed-mongo-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurigshankar%2Fspring-cosmos-change-feed-mongo-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurigshankar%2Fspring-cosmos-change-feed-mongo-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurigshankar%2Fspring-cosmos-change-feed-mongo-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaurigshankar","download_url":"https://codeload.github.com/gaurigshankar/spring-cosmos-change-feed-mongo-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurigshankar%2Fspring-cosmos-change-feed-mongo-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29419236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["changefeed","changestreams","cosmosdb","java","mongodb","reactive-programming","spring-boot","spring-reactive"],"created_at":"2026-02-13T21:45:28.028Z","updated_at":"2026-02-13T21:45:28.690Z","avatar_url":"https://github.com/gaurigshankar.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Cosmos Change Feed Demo App\n\nSimple Demo For Cosmos [Change Feed](https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed) while using \n[MongoDB API](https://docs.microsoft.com/en-us/azure/cosmos-db/mongodb-introduction) \n\nMongoDB natively has [ChangeStream](https://docs.mongodb.com/manual/changeStreams/) that is synonomous with Change Feed Of CosmosDB.\n\nWhen using CosmosDB with MongoDB API,  We can just use MongoDB Change Stream directly. We just have to be aware,\n the entire MongoDB ChangeStream functionalities may not be supported by CosmosDB. Check \n [Limitations](https://docs.microsoft.com/en-us/azure/cosmos-db/mongodb-change-streams#current-limitations)  \n\n### Demo APP\n\nIn the Demo App, there are two Collections Employee \u0026 DuplicateEmployee. The App listens for \nChangeFeed/ChangeStream messages on Employee Collection and inserts/updates the same Document into DuplicateEmployee Collection.\n\n### PreReqs\n1) Access To Azure CosmosDB\n2) Ensure MongoDB APi 3.6 version is used / enabled in Azure Portal\n3) Ensure MongoDB Aggregation Pipeline is enabled in Azure Portal\n4) Create New DB / Use Existing DB\n5) Create two Collections named Employee and DuplicateEmployee\n6) Rename [src/main/resources/sample_application.properties](./src/main/resources/sample_application.properties) to `application.properties`\n7) Modify `src/main/resources/application.properties` to update MONGO URI and DB Name specific to your azure account\n\n### Reactive Java\nReactive programming is a programming paradigm that deals with asynchronous data streams (sequences of events) \nand the specific propagation of change, which means it implements modifications to the execution \nenvironment (context) in a certain order. [More Details](https://www.scnsoft.com/blog/java-reactive-programming)\nBeing Spring boot project uses [Spring Reactive](https://spring.io/reactive). This is used via below dependency\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-starter-data-mongodb-reactive\u003c/artifactId\u003e\n    \u003cversion\u003e2.2.6.RELEASE\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Execute\n1) This is a typical Spring Boot APP. Run `com.gauri.cosmosdemo.Main` class.\n2) Using Azure portal add a new Document to Employee Collection as per below structure. This App would have listened \nto changes in Employee Collection and inserted/updates a document in DuplicateEmployee Collection.\n```\n{\n    \"_id\": 4,\n    \"name\": \"Gauri\",\n    \"department\": \"IT\",\n    \"designation\": \"Engg\"\n}\n```\n\n### EmployeeChangeFeedListener\n[EmployeeChangeFeedListener.java](./src/main/java/com/gauri/cosmosdemo/db/changefeed/EmployeeChangeFeedListener.java) \nsets up and subscribes to the ChangeStream of Employee Collection and acts to process the change \n(ie) inserting / updating same document in DuplicateEmployee Collection.\n\n### Rest Endpoints For Testing\nFew Rest Endpoints are powered by Demo App via [TestServiceController.java](./src/main/java/com/gauri/cosmosdemo/service/TestServiceController.java)\nOnce Server is running, base path of the endpoints are http://localhost:8080/cosmosdemo/test\n\n| Path | Type | Functionality |\n| - | - | - |\n| http://localhost:8080/cosmosdemo/test/allEmployees | GET | Gets all Documents from Employee Collection |\n| http://localhost:8080/cosmosdemo/test/statusChangeFeedEmployee | GET | Gets the status of Employee Change Feed Subscription that informs, if the subscription is active |\n| http://localhost:8080/cosmosdemo/test/terminateChangeFeedEmployee | GET | Terminates the Employee Change Feed Subscription |\n| http://localhost:8080/cosmosdemo/test/insertEmployee |  POST  \u003cpre lang=\"json\"\u003e{\u003cbr\u003e \"_id\": 4, \u003cbr\u003e \"name\": \"Gauri\", \u003cbr\u003e \"department\": \"IT\", \u003cbr\u003e  \"designation\": \"Engg\" \u003cbr\u003e } \u003c/pre\u003e  | Insert a document into Employee Collection |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaurigshankar%2Fspring-cosmos-change-feed-mongo-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaurigshankar%2Fspring-cosmos-change-feed-mongo-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaurigshankar%2Fspring-cosmos-change-feed-mongo-api/lists"}