Azure Cosmos DB
An Azure NoSQL database service for app development.
974 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am using azure cosmos db and all of the sudden, it stopped working with the error bellow
Method called:
cosmosDatabase.createContainerIfNotExists(containerProperties);
java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread parallel-10
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.4.5.jar:3.4.5]
at reactor.core.publisher.Mono.block(Mono.java:1703) ~[reactor-core-3.4.5.jar:3.4.5]
at com.azure.cosmos.CosmosDatabase.blockContainerResponse(CosmosDatabase.java:288) ~[azure-cosmos-4.14.0.jar:na]
at com.azure.cosmos.CosmosDatabase.createContainerIfNotExists(CosmosDatabase.java:195) ~[azure-cosmos-4.14.0.jar:na]
method called save()
java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread parallel-12
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.4.5.jar:3.4.5]
at reactor.core.publisher.Mono.block(Mono.java:1703) ~[reactor-core-3.4.5.jar:3.4.5]
at com.azure.cosmos.CosmosContainer.blockItemResponse(CosmosContainer.java:235) ~[azure-cosmos-4.14.0.jar:na]
at com.azure.cosmos.CosmosContainer.createItem(CosmosContainer.java:156) ~[azure-cosmos-4.14.0.jar:na]
at service.save(CosmosRepositoryImpl.java:33) ~[classes/:
notice that I am not using Async database.
A bit more of context:
it is is being processed inside a stream where I get a Flux object and iterate over it, and the
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-starter-cosmos</artifactId>
<version>3.4.0</version>
</dependency>
A react controller call the bellow methods. P.S notice that I changed the names business-related.
`
Service class:
public Mono<ResponseObect> myMethod(final RequestObject request) {
return getSomeFlux(request).flatMap(someObject -> {
RepositoryClass.save(someObject);
return Flux.just(someObject);
}
).count().map(ResponseObect::new);
}
Repo Class:
public void save(final MyObject newItem, final String containerName) {
CosmosContainer container = getContainer(containerName);
CosmosItemResponse<MyObject> savedItem = container.createItem(newItem);
if (savedItem.getStatusCode() != 201) {
do logging
}
}
private CosmosContainer getContainer(final String containerName) {
CosmosUtils.createContainerIfNotExists(containerName, cosmosDatabase);
return cosmosDatabase.getContainer(containerName);
}
Hi Saurabh, thank you for interaction, I updated the question with a bit more of details
Investigating a bit deeper Cosmos db api, it is using block, even though I am not using the Async database.
I don't like the idea of using reactive methods when I choose the no Async client, database, container....
But what I did that solved the problem was replacing my objects with async ones.
But some weird behavior happens, my Consumer(the one I am passing to
subscribe(consumer)
) is only getting executed when the container already exists, otherwise, it is not even though the container is being created.And also it is strange to me why it was working before and all of the sudden it has stopped
Hi @Claudio Resende ,
Thanks for sharing the information. I am checking internally on the same and get back to you.
Thanks
Saurabh
Hi @Claudio Resende ,
Sorry for the delay on this. I am still waiting for products team response on this issue and update you on as soon as I hear back.
Thanks
Saurabh
Sign in to comment