{"id":6178,"date":"2023-05-23T08:00:28","date_gmt":"2023-05-23T15:00:28","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=6178"},"modified":"2023-05-23T10:25:17","modified_gmt":"2023-05-23T17:25:17","slug":"real-time-data-processing-with-new-azure-cosmos-db-change-feed-modes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/real-time-data-processing-with-new-azure-cosmos-db-change-feed-modes\/","title":{"rendered":"Real time data processing with new Azure Cosmos DB change feed modes"},"content":{"rendered":"<p><span class=\"TextRun SCXW157320932 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW157320932 BCX8\">The Azure Cosmos DB change feed <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">allows<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\"> applications <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">to <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">seamlessly <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">r<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">eact to real time changes <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">to data<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">! <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">It\u2019s<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\"> a persistent record of changes to items in your container in the order<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\"> they occurred.<\/span> <span class=\"NormalTextRun SCXW157320932 BCX8\">Instead of writing complex code to query <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">recently<\/span> <span class=\"NormalTextRun SCXW157320932 BCX8\">modified documents, <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">manually <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">track<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">\u00a0checkpointin<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">g<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">,<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\"> and handle retries for errors in processing<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">, <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">the change feed <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">provides<\/span> <span class=\"NormalTextRun SCXW157320932 BCX8\">ways to manage this for you<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">.<\/span> <span class=\"NormalTextRun SCXW157320932 BCX8\">The c<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">hange feed makes<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\"> scenarios like<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\"> triggering notifications based<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\"> on<\/span><span class=\"NormalTextRun SCXW157320932 BCX8\"> updates to your data, real-time stream processing, and data movement <\/span><span class=\"NormalTextRun SCXW157320932 BCX8\">even easier!<\/span><\/span><span class=\"EOP SCXW157320932 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"TextRun SCXW8233296 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW8233296 BCX8\" data-ccp-parastyle=\"heading 1\">Change feed modes<\/span><\/span><\/h2>\n<p><span lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\">The change feed is available in two modes, each sharing the same core concepts with key differences. Differences include the operations captured in the feed, metadata available for each change, and the retention period of changes. Multiple applications can simultaneously read the change feed for the same container in different modes to fit the requirements of your workload.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"TextRun SCXW105790836 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW105790836 BCX8\" data-ccp-parastyle=\"heading 2\">Latest version <\/span><span class=\"NormalTextRun SCXW105790836 BCX8\" data-ccp-parastyle=\"heading 2\">mode<\/span><\/span><span class=\"EOP SCXW105790836 BCX8\" data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">If you\u2019ve used change feed before, you\u2019ve used latest version mode. Latest version mode is widely used to build reactive applications and was previously the only way to read change feed. This mode captures changes from insert and update operations. It always gives you the latest version of all items in the container. Documents aren&#8217;t available in the feed once they&#8217;re deleted, and you won\u2019t get a record of their deletion in the change feed. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">In latest version mode you can process the change feed going back to the beginning of the container. Changes will always be available in the feed if there are still items in the container. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"TextRun SCXW189973478 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW189973478 BCX8\" data-ccp-parastyle=\"heading 2\">New<\/span><span class=\"NormalTextRun SCXW189973478 BCX8\" data-ccp-parastyle=\"heading 2\">: <\/span><span class=\"NormalTextRun SCXW189973478 BCX8\" data-ccp-parastyle=\"heading 2\">All versions and <\/span><span class=\"NormalTextRun SCXW189973478 BCX8\" data-ccp-parastyle=\"heading 2\">deletes<\/span><span class=\"NormalTextRun SCXW189973478 BCX8\" data-ccp-parastyle=\"heading 2\"> mode<\/span><span class=\"NormalTextRun SCXW189973478 BCX8\" data-ccp-parastyle=\"heading 2\"> (<\/span><span class=\"NormalTextRun SCXW189973478 BCX8\" data-ccp-parastyle=\"heading 2\">Public <\/span><span class=\"NormalTextRun SCXW189973478 BCX8\" data-ccp-parastyle=\"heading 2\">Preview)<\/span><\/span><span class=\"EOP SCXW189973478 BCX8\" data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">All versions and deletes change feed mode solves some of the key gaps in latest version mode! Every change to items in your container appears in the change feed when using this mode- including when multiple changes to a single item occur between change feed reads and when an item is deleted. Deletes from both explicit delete operations and TTL expirations are captured. Previously, there was no way to be notified when an item expired due to TTL, even if you used the \u201csoft delete\u201d pattern. This mode gives you a full view of the state of your container without any custom logic or soft deletes.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">In order to read the change feed in all versions and deletes mode, <\/span><a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/continuous-backup-restore-introduction\"><span data-contrast=\"none\">continuous backups<\/span><\/a><span data-contrast=\"auto\"> must be enabled on your Azure Cosmos DB account. The retention period of all versions and deletes change feed depends on the retention period configured for continuous backups. You can process and reprocess changes in this mode as long as the changes occurred within the retention period.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"TextRun SCXW149928174 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW149928174 BCX8\" data-ccp-parastyle=\"heading 1\">The change feed now serves more use cases<\/span><\/span><\/h2>\n<p><span data-contrast=\"auto\">Regardless of the mode you read it in, the Azure Cosmos DB change feed allows for efficient processing of items that have changed in a container. Latest version mode may be the best fit for your workload in many scenarios, especially if you need to process changes from the beginning of your container. In addition to the <\/span><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/nosql\/change-feed-design-patterns\"><span data-contrast=\"none\">core use cases<\/span><\/a><span data-contrast=\"auto\"> for change feed, all versions and deletes mode enhances many patterns like event sourcing and data movement, as well as enables new ones like auditing.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span class=\"TextRun SCXW246131820 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW246131820 BCX8\">Some use cases that are a great fit for all versions and <\/span><span class=\"NormalTextRun SCXW246131820 BCX8\">deletes<\/span><span class=\"NormalTextRun SCXW246131820 BCX8\"> mode are:<\/span><\/span><span class=\"EOP SCXW246131820 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;multilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"1\" data-aria-level=\"1\"><span data-contrast=\"auto\">Real-time transfer of data between two locations without having to implement a soft delete\u00a0<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559685&quot;:1290,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;multilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"auto\">Triggering logic based on all changes if multiple change operations for a given item occur between change feed reads<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559685&quot;:1290,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;multilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"auto\">Triggering alerts on delete operations<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559685&quot;:1290,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;multilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"auto\">The ability to process item creates, updates, and deletes differently based on operation type<\/span><span data-ccp-props=\"{&quot;134233117&quot;:true,&quot;134233118&quot;:true,&quot;201341983&quot;:0,&quot;335559685&quot;:1290,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><span class=\"TextRun SCXW262083672 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW262083672 BCX8\" data-ccp-parastyle=\"heading 1\">Sign up for <\/span><span class=\"NormalTextRun ContextualSpellingAndGrammarErrorV2Themed SCXW262083672 BCX8\" data-ccp-parastyle=\"heading 1\">the<\/span><span class=\"NormalTextRun ContextualSpellingAndGrammarErrorV2Themed SCXW262083672 BCX8\" data-ccp-parastyle=\"heading 1\"> all<\/span><span class=\"NormalTextRun SCXW262083672 BCX8\" data-ccp-parastyle=\"heading 1\"> versions and <\/span><span class=\"NormalTextRun SCXW262083672 BCX8\" data-ccp-parastyle=\"heading 1\">deletes<\/span><span class=\"NormalTextRun SCXW262083672 BCX8\" data-ccp-parastyle=\"heading 1\"> mode<\/span><span class=\"NormalTextRun SCXW262083672 BCX8\" data-ccp-parastyle=\"heading 1\"> Public Preview<\/span><\/span><span class=\"EOP SCXW262083672 BCX8\" data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;201341983&quot;:0,&quot;335559738&quot;:240,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span class=\"TextRun SCXW58665040 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW58665040 BCX8\">Enroll in the preview <\/span><span class=\"NormalTextRun SCXW58665040 BCX8\">for all versions and <\/span><span class=\"NormalTextRun SCXW58665040 BCX8\">deletes<\/span><span class=\"NormalTextRun SCXW58665040 BCX8\"> change feed mode via the <\/span><\/span><a class=\"Hyperlink SCXW58665040 BCX8\" href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/azure-resource-manager\/management\/preview-features?tabs=azure-portal\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW58665040 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW58665040 BCX8\" data-ccp-charstyle=\"Hyperlink\">Preview Features<\/span><\/span><\/a><span class=\"TextRun SCXW58665040 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW58665040 BCX8\"> page in the Azure Portal. Search for the<\/span><span class=\"NormalTextRun SCXW58665040 BCX8\">\u00a0<\/span><\/span><strong><span class=\"TextRun SCXW58665040 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW58665040 BCX8\">AllVersionsAndD<\/span><span class=\"NormalTextRun SCXW58665040 BCX8\">eletesC<\/span><span class=\"NormalTextRun SCXW58665040 BCX8\">hangeFeed<\/span><\/span><\/strong><span class=\"TextRun SCXW58665040 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW58665040 BCX8\">\u00a0feature to register<\/span><\/span><span class=\"TextRun SCXW58665040 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW58665040 BCX8\">.<\/span><span class=\"NormalTextRun SCXW58665040 BCX8\">\u00a0<\/span><\/span><span class=\"EOP SCXW58665040 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:2,&quot;335559739&quot;:160,&quot;335559740&quot;:285}\">\u00a0<\/span><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/05\/EnrollInChangeFeedPreview-1.png\"><img decoding=\"async\" class=\"wp-image-6265 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/05\/EnrollInChangeFeedPreview-1-300x133.png\" alt=\"Enroll in the all versions and deletes change feed preview\" width=\"750\" height=\"332\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/05\/EnrollInChangeFeedPreview-1-300x133.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/05\/EnrollInChangeFeedPreview-1-1024x453.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/05\/EnrollInChangeFeedPreview-1-768x339.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2023\/05\/EnrollInChangeFeedPreview-1.png 1249w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"TextRun SCXW146580066 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW146580066 BCX8\">After signing up for the <\/span><span class=\"NormalTextRun SCXW146580066 BCX8\">preview, expect a response to the email you used to sign up<\/span><span class=\"NormalTextRun SCXW146580066 BCX8\"> with<\/span><span class=\"NormalTextRun SCXW146580066 BCX8\">in about a week<\/span><span class=\"NormalTextRun SCXW146580066 BCX8\">. <\/span><span class=\"NormalTextRun SCXW146580066 BCX8\">Once approved, <\/span><span class=\"NormalTextRun SCXW146580066 BCX8\">you\u2019ll<\/span><span class=\"NormalTextRun SCXW146580066 BCX8\"> need to ensure that <\/span><\/span><a class=\"Hyperlink SCXW146580066 BCX8\" href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/continuous-backup-restore-introduction\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW146580066 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW146580066 BCX8\" data-ccp-charstyle=\"Hyperlink\">continuous backups<\/span><\/span><\/a><span class=\"TextRun SCXW146580066 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW146580066 BCX8\"> are enabled on your Azure Cosmos DB account<\/span><span class=\"NormalTextRun SCXW146580066 BCX8\"> before you can read the change feed in all versions and <\/span><span class=\"NormalTextRun SCXW146580066 BCX8\">deletes<\/span><span class=\"NormalTextRun SCXW146580066 BCX8\"> mode.<\/span><\/span><span class=\"EOP SCXW146580066 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"TextRun SCXW183662395 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW183662395 BCX8\" data-ccp-parastyle=\"heading 1\">Get started using all versions and <\/span><span class=\"NormalTextRun SCXW183662395 BCX8\" data-ccp-parastyle=\"heading 1\">deletes<\/span><span class=\"NormalTextRun SCXW183662395 BCX8\" data-ccp-parastyle=\"heading 1\"> mode<\/span><\/span><span class=\"EOP SCXW183662395 BCX8\" data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;201341983&quot;:0,&quot;335559738&quot;:240,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span class=\"TextRun SCXW263855765 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW263855765 BCX8\">After being enrolled in the preview and <\/span><span class=\"NormalTextRun SCXW263855765 BCX8\">configuring <\/span><\/span><a class=\"Hyperlink SCXW263855765 BCX8\" href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/continuous-backup-restore-introduction\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW263855765 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW263855765 BCX8\" data-ccp-charstyle=\"Hyperlink\">continuous backups<\/span><\/span><\/a><span class=\"TextRun SCXW263855765 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW263855765 BCX8\">, <\/span><span class=\"NormalTextRun SCXW263855765 BCX8\">you\u2019re<\/span><span class=\"NormalTextRun SCXW263855765 BCX8\"> ready to get started using all versions and <\/span><span class=\"NormalTextRun SCXW263855765 BCX8\">deletes<\/span><span class=\"NormalTextRun SCXW263855765 BCX8\"> mode!<\/span> <span class=\"NormalTextRun SCXW263855765 BCX8\">During the preview you can read the change feed using the <\/span><\/span><a class=\"Hyperlink SCXW263855765 BCX8\" href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/nosql\/change-feed-processor?tabs=java\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW263855765 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW263855765 BCX8\" data-ccp-charstyle=\"Hyperlink\">change feed processor in Java<\/span><\/span><\/a><span class=\"TextRun SCXW263855765 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW263855765 BCX8\">, or using the <\/span><\/span><a class=\"Hyperlink SCXW263855765 BCX8\" href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/nosql\/change-feed-pull-model?tabs=dotnet#consuming-an-entire-containers-changes\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW263855765 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW263855765 BCX8\" data-ccp-charstyle=\"Hyperlink\">pull model<\/span><\/span><\/a><span class=\"TextRun SCXW263855765 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW263855765 BCX8\"> in either .NET or Java.<\/span><\/span><span class=\"EOP SCXW263855765 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span class=\"TextRun SCXW26703439 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW26703439 BCX8\">Here\u2019s<\/span><span class=\"NormalTextRun SCXW26703439 BCX8\"> a sample change feed processor <\/span><span class=\"NormalTextRun SCXW26703439 BCX8\">implementation<\/span><span class=\"NormalTextRun SCXW26703439 BCX8\"> in Java<\/span><span class=\"NormalTextRun SCXW26703439 BCX8\">. <\/span><span class=\"NormalTextRun ContextualSpellingAndGrammarErrorV2Themed SCXW26703439 BCX8\">The<\/span> <\/span><a class=\"Hyperlink SCXW26703439 BCX8\" href=\"https:\/\/github.com\/Azure-Samples\/azure-cosmos-java-sql-api-samples\/blob\/main\/src\/main\/java\/com\/azure\/cosmos\/examples\/changefeed\/SampleChangeFeedProcessorForAllVersionsAndDeletesMode.java\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW26703439 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW26703439 BCX8\" data-ccp-charstyle=\"Hyperlink\">full sample<\/span><\/span><\/a><span class=\"TextRun SCXW26703439 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW26703439 BCX8\"> can be found on GitHub.<\/span><\/span><span class=\"EOP SCXW26703439 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"prettyprint language-java\"><code class=\"language-java\">ChangeFeedProcessor changeFeedProcessorInstance = new ChangeFeedProcessorBuilder() \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f .hostName(hostName) \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f .options(options) \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f .feedContainer(feedContainer) \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f .leaseContainer(leaseContainer) \r\n\u202f               .handleAllVersionsAndDeletesChanges((List&lt;ChangeFeedProcessorItem&gt; changeFeedProcessorItems) -&gt; { \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f logger.info(\"---&gt;handleAllVersionsAndDeletesChanges() START\"); \r\n\r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f for (ChangeFeedProcessorItem item : changeFeedProcessorItems) { \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f try { \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \/\/ All versions and deletes change feed items are in the form of ChangeFeedProcessorItem\r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \/\/ You can call the different getters for different states, as shown below. Different operations populate each state differently. \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f logger.info(\"----&gt;CURRENT ITEM VERSION RECEIVED: {}\", item.getCurrent()); \/\/ Populated for create and replace operations. \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f logger.info(\"----&gt;PREVIOUS ITEM VERSION RECEIVED: {}\", item.getPrevious()); \/\/ Populated for delete operations. \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f logger.info(\"----&gt;METADATA RECEIVED: {}\", item.getChangeFeedMetaData()); \/\/ Populated all operations. \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f } catch (JsonProcessingException e) { \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f e.printStackTrace(); \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f } \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f } \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f logger.info(\"---&gt;handleAllVersionsAndDeletesChanges() END\"); \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f }) \r\n\u202f \u202f \u202f \u202f \u202f \u202f \u202f \u202f .buildChangeFeedProcessor(); <\/code><\/pre>\n<p>&nbsp;<\/p>\n<h2><span class=\"TextRun SCXW148250336 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW148250336 BCX8\" data-ccp-parastyle=\"heading 1\">Learn more<\/span><\/span><span class=\"EOP SCXW148250336 BCX8\" data-ccp-props=\"{&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;201341983&quot;:0,&quot;335559738&quot;:240,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<ul style=\"font-weight: 400;\">\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"1\" data-aria-level=\"1\"><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/change-feed\"><span data-contrast=\"none\">Working with the change feed &#8211; Azure Cosmos DB | Microsoft Learn<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"2\" data-aria-level=\"1\"><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/nosql\/read-change-feed\"><span data-contrast=\"none\">Reading Azure Cosmos DB change feed | Microsoft Learn<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"3\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"3\" data-aria-level=\"1\"><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/nosql\/change-feed-design-patterns\"><span data-contrast=\"none\">Change feed design patterns in Azure Cosmos DB | Microsoft Learn<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<\/ul>\n<h3 id=\"get-started-with-azure-cosmos-db-for-free\"><strong>Get Started with Azure Cosmos DB for free<\/strong><i class=\"fabric-icon fabric-icon--Link\" aria-hidden=\"true\"><\/i><\/h3>\n<p><a href=\"https:\/\/azure.microsoft.com\/en-us\/products\/cosmos-db\/\" target=\"_blank\" rel=\"noopener\">Azure Cosmos DB<\/a>\u00a0is a fully managed NoSQL and relational database for modern app development with SLA-backed speed and availability, automatic and instant scalability, and support for open source PostgreSQL, MongoDB and Apache Cassandra.\u00a0<a href=\"https:\/\/cosmos.azure.com\/try\/\" target=\"_blank\" rel=\"noopener\">Try Azure Cosmos DB for free here<\/a>. To stay in the loop on Azure Cosmos DB updates, follow us on\u00a0<a href=\"https:\/\/twitter.com\/AzureCosmosDB\" target=\"_blank\" rel=\"noopener\">Twitter<\/a>,\u00a0<a href=\"https:\/\/www.youtube.com\/AzureCosmosDB\" target=\"_blank\" rel=\"noopener\">YouTube<\/a>, and\u00a0<a href=\"https:\/\/www.linkedin.com\/company\/azure-cosmos-db\/\" target=\"_blank\" rel=\"noopener\">LinkedIn<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Azure Cosmos DB change feed allows applications to seamlessly react to real time changes to data! It\u2019s a persistent record of changes to items in your container in the order they occurred. Instead of writing complex code to query recently modified documents, manually track\u00a0checkpointing, and handle retries for errors in processing, the change feed [&hellip;]<\/p>\n","protected":false},"author":94159,"featured_media":6182,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-6178","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-sql-api"],"acf":[],"blog_post_summary":"<p>The Azure Cosmos DB change feed allows applications to seamlessly react to real time changes to data! It\u2019s a persistent record of changes to items in your container in the order they occurred. Instead of writing complex code to query recently modified documents, manually track\u00a0checkpointing, and handle retries for errors in processing, the change feed [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/6178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/94159"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=6178"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/6178\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/6182"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=6178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=6178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=6178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}