Page 1 of 1

Question about java

Posted: Wed Apr 12, 2023 11:28 am
by GiovanniMeazza
Hello, first of all, i'd like to thank you Scott for everything you've done for all the community of developer, your help is always precious.
Thereafter, i'm facing a doubt on the best way to develop a new procedure which has to use and keep alive a java virtual machine, i know java methods can be used directly from rpg and also invoked from qshell, but i'm not able to find the difference regarding performance and impact on system resources between this two methods.
Any suggestion is appreciated,or also, if anyone has a suggestion on how to test the system impact of jvm and java procedure is well accepted.
Thanks all
Bye

Re: Question about java

Posted: Wed Apr 12, 2023 3:58 pm
by jonboy49
The JVM is tied to the job and lives only as long as the job. That is the biggest issue most people face.

For a long running "service" provided in Java most submit a never-ending-job to batch and interact with it via data queues. There is an open source engine for this - but I'm danged if I can recall the name and have to go out now. Will try and lopcate it on my return.

Re: Question about java

Posted: Wed Apr 12, 2023 4:04 pm
by jonboy49
Just remembered. It is AppServer4RPG and you can find it here: https://sourceforge.net/projects/appserver4rpg/

Great tool.

Re: Question about java

Posted: Thu Apr 13, 2023 3:46 am
by Scott Klement
Also, calling Java from RPG is done using the Java Invocation API, which can disable certain types of optimization -- and therefore can negatively affect performance.

The "best" way to do this is to run the Java code in an application server, and code it as a REST API that you can call from your RPG code. Alternately, you can do something similar with data queues, etc... but keep in mind that this will make it proprietary (data queues are not cross-platform or available to all programming environments.)