Select to view content in your preferred language

Java SOE and multithreading

3209
6
04-10-2014 05:20 AM
MatthesRieke
Deactivated User
Hi,

I am developing an SOE using Java for AGS 10.2. For some interactions with the operations of the SOE a set of database queries are required that may take a few minutes. In order to speed things up, I have developed a little caching component that dumps the results of these queries into a file on the HDD.

What I am struggling now with: this caching component should run in the background as a maintenance task. Now, whenever this task runs (and it runs for several minutes) the interaction with the operations of the SOE is not possible any longer. It seems like it is locked by the background task. It even does not reach the "handleRESTRequest(...)" method.

I could not find any documentation regarding locking and threading in SOE development. Is this intended behaviour? And if so, is there any workaround you could think of? I just don't want the service to block whenever my cache is updating.

Thanks,
Matthes
0 Kudos
6 Replies
ChunjieXu
Emerging Contributor
I also increase the memory heap as suggested in the document, the problem still exist.
0 Kudos
ChunjieXu
Emerging Contributor
After the error, there are two new directory "install", "ServerObjectExt" and a jar file in the project folder, but the .soe file is missing,as the flowing picture shows:

     [ATTACH=CONFIG]33037[/ATTACH]
0 Kudos
MatthesRieke
Deactivated User
wrong thread, I guess?
0 Kudos
ChunjieXu
Emerging Contributor
en,Sorry for that.
0 Kudos
ChunjieXu
Emerging Contributor
For your quesitons, is it possible to use 2 SOEs? one for caching and the other to do the normal task?
0 Kudos
RichardWatson
Deactivated User
An SOE is associated with a map service.  Map services are configured to be high isolation or low isolation and the minimum and maximum number of instances are also specified.  How is yours configured?

I have an SOE which creates a background thread when IObjectConstruct.Construct is called and it works fine.  The thread takes some time but it does not use ArcObjects.  ArcObjects are COM STA and do not deal with multi-threading well.  ESRI refers to the model as "threads in isolation".  I have seen very little multi-threaded ArcObject code.

My code is written in .NET but my >guess< is that this point is probably not relevant.

My assumption is that you have exposed a function via the SOE and are calling it.  That function is taking minutes to complete and you are unable to make other REST calls while that function is running.  This could relate to how you configured the map service (hence my first question).  Is the long running operation occurring on a background thread or on the thread on which the SOE is waiting for a response?

An SOE extends/exposes HTTP actions.  HTTP actions are not intended to be long running and typically have timeouts associated with them.  If you are making a REST call which takes several minutes to complete then I think that you are doing the wrong thing.  One alternative is to use something like GeoProcessing -or- do something like have your request issue a ticket as a response which the client can then use to check the progress status.
0 Kudos