DEV Community

Using the new Azure SDK for Java to upload images asynchronously, using Spring Reactor

Julien Dubois on September 04, 2019

The new Azure SDK for Java This blog post uses the upcoming Azure SDK for Java: at the time of this writing, this is still a preview rel...
Collapse
 
anbusampath profile image
Anbu Sampath

when I tried executing the example with Spring Boot 2.1.8.RELEASE (webflux starter) got below exception. is Azure SDK required minimum reactor-netty verion ? Spring Boot uses different reactor-netter version. I could see only dependency version difference between both.

reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3
Caused by: java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:77) ~[reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at reactor.core.publisher.Mono.block(Mono.java:1494) ~[reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at com.azure.core.implementation.RestProxy.createResponse(RestProxy.java:456) ~[azure-core-1.0.0-preview.3.jar:na]
at com.azure.core.implementation.RestProxy.lambda$handleRestResponseReturnType$5(RestProxy.java:396) ~[azure-core-1.0.0-preview.3.jar:na]
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107) ~[reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]

Collapse
 
jdubois profile image
Julien Dubois

I don't think this issue is linked to the Netty version - it seems you are doing a blocking call at some point, and that's more likely to be the issue.
Did you change anything in the sample code, or just run it without any modification? I might have done an error when copy/pasting the code at some point.
If you have doubts about the Netty versions, I would use the one from Spring Boot, as it's using it far more extensively so you'll reduce the number of potential issues.

Collapse
 
anbusampath profile image
Anbu Sampath

I haven't modified the code, only I changed boot version to 2.1.8. But it worked as expected on 2.2.0 milestone and snapshot build.

Collapse
 
stealthmusic profile image
Jan Wedel

In my opinion, this is best suited in a microservice architecture, where you will code some specific services with a reactive API, and some with a traditional thread-based API.

This is a really important side note. Uploading (or downloading) files is a good use case for a reactive server. Also long living connections like streaming are. Other use cases probably aren’t.

Collapse
 
_hs_ profile image
HS

Thanks, this could come in handy. Do you have any suggestions for API built with Micronaut on how to deploy to Azure or better yet is it as supported as Spring?

Collapse
 
jdubois profile image
Julien Dubois

I'm guessing you only want to deploy a Micronaut application to Azure, so for this you don't really need to learn about the SDK (the SDK is if you want to use some specific Azure service from your Micronaut application - I guess it works the same as any other Java application, but you won't benefit from Spring Webflux like I do in this post).
In that case, we have a tutorial just for you : guides.micronaut.io/micronaut-azur... :-)

Collapse
 
_hs_ profile image
HS

Thank you, I've seen the docs before but I was worried about this "JDK 8 installed with JAVA_HOME configured appropriately (cannot be Java 9 or later)". So I got the impresion that Spring has a bit more to offer. There's too much stuff to do with deploying Java to Azure when I was hoping for Azure DevOps to provide simple solution as for other technologies. I guess I will try to set this up on DevOps later whitout Azure CLI and such and I'll hope it will support JDK 11 otherwise it will be switch from Azure or to .NET Core.

Thread Thread
 
jdubois profile image
Julien Dubois

Where did you see this Java 8 requirement? I'm using Java 11 for all this sample code, and had no problem at all.

Thread Thread
 
_hs_ profile image
HS

In the link you provided, I saw the link couple of days ago but didn't read it fully just saw the limitation but it's for the computer being used to develop as far as I can see. I'm not sure is it because of other steps the in the documentation or something else.

Collapse
 
darkain profile image
Vincent Milum Jr

Wait wait wait... I'm genuinely curious now. Do we really have "React" in JavaScript and "Reactor" in Java now!?

Collapse
 
jdubois profile image
Julien Dubois

Of yes, you have "reactive" applications in Java, and that's not the same thing as "React" in the front-end! It also doesn't mean what UX/UI people call "reactive".

Collapse
 
cheo2322 profile image
Sergio Hidalgo

some alternative for getOrCreateContainer("name")?