opensourceBIM / BIMserver

The open source BIMserver platform
GNU Affero General Public License v3.0
1.56k stars 611 forks source link

Async check in not working as aspected (behaves like sync) #1248

Closed PaoloBertuzzo closed 2 years ago

PaoloBertuzzo commented 2 years ago

While checking in a new model, using Java client (ver. 1.5.182), the async checkin behaves like the sync checkin version, returning only when the model has been fully imported.

Steps to reproduce the behavior:

        _SProject project = client.getServiceInterface().getProjectByPoid(Long.parseLong(projectId));

        long topicId = client.checkinAsync(project.getOid(), comment, Long.parseLong(deserializerId), 
                false, file.toPath(), -1);_

the method "checkinAsync" does not return to client since the model is fully uploaded. Can we have a snippet reproducing a right async checkin returning a topic id we can query on for the status?

Thanks

hlg commented 2 years ago

Correct, the HTTP request to upload will only return after the data is transferred to the server. However, that does not mean that processing on the server is finished and here is the difference between synchronous and asynchronous checkin: With async the the server responds directly after upload is finished (which is as early as possible), with sync only after processing is finished. The difference will be less notable with streaming deserializers, because with streaming deserializers processing starts in parallel while data is still uploading.

You can call client.getServiceInterface().initiateCheckin(poid, deserializerOid) in order to retrieve a topicId upfront and use that as a parameter in your checkinAsync call. However, to make use of it during the running upload, you would need to make the HTTP request in an asynchronous manner on the client side. I think the current HTTP client in the Java client library is not asynchronous. Have a look at the async client variants in Apache HttpClient if you are interested to tinker with the client library. There are some other fixes and improvements we would like to make in the Java client library, including upgrade to HttpClient version 5. Will keep this as an additional feature request.

PaoloBertuzzo commented 2 years ago

Ok, works. Thanks for the hint.