|
1 | 1 | ---
|
2 |
| -title: Diagnose and troubleshoot Azure Cosmos DB Java Async SDK |
3 |
| -description: Use features like client-side logging and other third-party tools to identify, diagnose, and troubleshoot Azure Cosmos DB issues. |
4 |
| -author: moderakh |
| 2 | +title: Diagnose and troubleshoot Azure Cosmos DB Async Java SDK v2 |
| 3 | +description: Use features like client-side logging and other third-party tools to identify, diagnose, and troubleshoot Azure Cosmos DB issues in Async Java SDK v2. |
| 4 | +author: anfeldma-ms |
5 | 5 | ms.service: cosmos-db
|
6 |
| -ms.date: 04/30/2019 |
7 |
| -ms.author: moderakh |
| 6 | +ms.date: 05/04/2020 |
| 7 | +ms.author: anfeldma |
8 | 8 | ms.devlang: java
|
9 | 9 | ms.subservice: cosmosdb-sql
|
10 | 10 | ms.topic: troubleshooting
|
11 | 11 | ms.reviewer: sngun
|
12 | 12 | ---
|
13 | 13 |
|
14 | 14 | # Troubleshoot issues when you use the Java Async SDK with Azure Cosmos DB SQL API accounts
|
| 15 | + |
| 16 | +> [!div class="op_single_selector"] |
| 17 | +> * [Java SDK v4](troubleshoot-java-sdk-v4-sql.md) |
| 18 | +> * [Async Java SDK v2](troubleshoot-java-async-sdk.md) |
| 19 | +> * [.NET](troubleshoot-dot-net-sdk.md) |
| 20 | +> |
| 21 | +
|
| 22 | +> [!IMPORTANT] |
| 23 | +> This is *not* the latest Java SDK for Azure Cosmos DB! Consider using Azure Cosmos DB Java SDK v4 for your project. Follow the instructions in the [Migrate to Azure Cosmos DB Java SDK v4](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/migration-guide.md) guide and [Reactor vs RxJava](https://github.com/Azure-Samples/azure-cosmos-java-sql-api-samples/blob/master/reactor-rxjava-guide.md) guide to upgrade. |
| 24 | +> |
| 25 | +> This article covers troubleshooting for Azure Cosmos DB Async Java SDK v2 only. See the Azure Cosmos DB Async Java SDK v2 [Release Notes](sql-api-sdk-async-java.md), [Maven repository](https://mvnrepository.com/artifact/com.microsoft.azure/azure-cosmosdb) and [performance tips](performance-tips-async-java.md) for more information. |
| 26 | +> |
| 27 | +
|
15 | 28 | This article covers common issues, workarounds, diagnostic steps, and tools when you use the [Java Async SDK](sql-api-sdk-async-java.md) with Azure Cosmos DB SQL API accounts.
|
16 | 29 | The Java Async SDK provides client-side logical representation to access the Azure Cosmos DB SQL API. This article describes tools and approaches to help you if you run into any issues.
|
17 | 30 |
|
@@ -75,6 +88,9 @@ The SDK uses the [Netty](https://netty.io/) IO library to communicate with Azure
|
75 | 88 | The Netty IO threads are meant to be used only for non-blocking Netty IO work. The SDK returns the API invocation result on one of the Netty IO threads to the app's code. If the app performs a long-lasting operation after it receives results on the Netty thread, the SDK might not have enough IO threads to perform its internal IO work. Such app coding might result in low throughput, high latency, and `io.netty.handler.timeout.ReadTimeoutException` failures. The workaround is to switch the thread when you know the operation takes time.
|
76 | 89 |
|
77 | 90 | For example, take a look at the following code snippet. You might perform long-lasting work that takes more than a few milliseconds on the Netty thread. If so, you eventually can get into a state where no Netty IO thread is present to process IO work. As a result, you get a ReadTimeoutException failure.
|
| 91 | + |
| 92 | +### <a id="asyncjava2-readtimeout"></a>Async Java SDK V2 (Maven com.microsoft.azure::azure-cosmosdb) |
| 93 | + |
78 | 94 | ```java
|
79 | 95 | @Test
|
80 | 96 | public void badCodeWithReadTimeoutException() throws Exception {
|
@@ -126,13 +142,19 @@ public void badCodeWithReadTimeoutException() throws Exception {
|
126 | 142 | assertThat(failureCount.get()).isGreaterThan(0);
|
127 | 143 | }
|
128 | 144 | ```
|
129 |
| - The workaround is to change the thread on which you perform work that takes time. Define a singleton instance of the scheduler for your app. |
130 |
| - ```java |
| 145 | +The workaround is to change the thread on which you perform work that takes time. Define a singleton instance of the scheduler for your app. |
| 146 | + |
| 147 | +### <a id="asyncjava2-scheduler"></a>Async Java SDK V2 (Maven com.microsoft.azure::azure-cosmosdb) |
| 148 | + |
| 149 | +```java |
131 | 150 | // Have a singleton instance of an executor and a scheduler.
|
132 | 151 | ExecutorService ex = Executors.newFixedThreadPool(30);
|
133 | 152 | Scheduler customScheduler = rx.schedulers.Schedulers.from(ex);
|
134 |
| - ``` |
135 |
| - You might need to do work that takes time, for example, computationally heavy work or blocking IO. In this case, switch the thread to a worker provided by your `customScheduler` by using the `.observeOn(customScheduler)` API. |
| 153 | +``` |
| 154 | +You might need to do work that takes time, for example, computationally heavy work or blocking IO. In this case, switch the thread to a worker provided by your `customScheduler` by using the `.observeOn(customScheduler)` API. |
| 155 | + |
| 156 | +### <a id="asyncjava2-applycustomscheduler"></a>Async Java SDK V2 (Maven com.microsoft.azure::azure-cosmosdb) |
| 157 | + |
136 | 158 | ```java
|
137 | 159 | Observable<ResourceResponse<Document>> createObservable = client
|
138 | 160 | .createDocument(getCollectionLink(), docDefinition, null, false);
|
@@ -165,7 +187,7 @@ Exception in thread "main" java.lang.NoSuchMethodError: rx.Observable.toSingle()
|
165 | 187 |
|
166 | 188 | The above exception suggests you have a dependency on an older version of RxJava lib (e.g., 1.2.2). Our SDK relies on RxJava 1.3.8 which has APIs not available in earlier version of RxJava.
|
167 | 189 |
|
168 |
| -The workaround for such issuses is to identify which other dependency brings in RxJava-1.2.2 and exclude the transitive dependency on RxJava-1.2.2, and allow CosmosDB SDK bring the newer version. |
| 190 | +The workaround for such issues is to identify which other dependency brings in RxJava-1.2.2 and exclude the transitive dependency on RxJava-1.2.2, and allow CosmosDB SDK bring the newer version. |
169 | 191 |
|
170 | 192 | To identify which library brings in RxJava-1.2.2 run the following command next to your project pom.xml file:
|
171 | 193 | ```bash
|
|
0 commit comments