Skip to content

snimmagadda1/azure-cosmos-stored-procedure-pagination-continuation

Repository files navigation

Example implementation of an Azure Cosmos DB stored procedure with pagination

When working with large data sets or long running processes in Cosmos, you should use continuation. Considering stored procedures have a 5 second timeout and are resource-limited, a robust stored procedure implementation must be used to return the continuation token to the client. This is a quick re-wiring of the java CRUD quickstart to query all items in a container with a continuation token.

The stored procedure is written using the JavaScript query api. It can be found at get-items-continuation.js.

The calling of the stored procedure while continuation != null is orchestrated by Java client code in com.azure.cosmos.sample.sync.SyncMain.

Prerequisites

  • Before you can run this sample, you must have the following prerequisites:

    • An active Azure account. If you don't have one, you can sign up for a free account. Alternatively, you can use the Azure Cosmos DB Emulator for this tutorial. As the emulator https certificate is self signed, you need to import its certificate to the java trusted certificate store as explained here.

    • JDK 1.8+

    • Maven

Quickstart

  • First clone this repository using
git clone https://github.com/snimmagadda1/azure-cosmos-stored-procedure-pagination-continuation.git
  • From a command prompt or shell, run the following command to compile and resolve dependencies.
cd azure-cosmos-stored-procedure-pagination-continuation
mvn clean package
  • From a command prompt or shell, run the following command to run the application.
mvn exec:java -Dexec.mainClass="com.azure.cosmos.sample.sync.SyncMain"                                                    

Observe database, container, and item creation followed by paginated querying using a stored proc.

About

Reference implementation of pagination in a Cosmos DB stored procedure

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published