How can I manage globals directly from a remote Java application in Cache (2016.1.1) without relying on cacheextreme.jar or requiring the application and Cache Server to run on the same machine?
I’m trying to find a way to manage globals from our Java application. We have two separate features:
-
Managing tables normally using SQL
-
Managing globals, since some globals exist without class or table definitions
Cache version : Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2016.1.1 (Build 108U_SU), Thu Jul 7 2016 09:39:04 EDT
I tried to retrieve the globals tree, update node values, and append nodes using SQL by calling stored procedures, but I couldn’t find any procedures for adding, updating, or deleting nodes.
I also tried using cacheextreme.jar to access the globals API directly. However, I noticed that this requires the Java application and the Cache Server to run on the same machine, since Java relies on liblcbjni.so to manage globals.
In our case, this is not possible because we deploy our Java application using Docker, while the Cache Server is already running on a separate server within our VPN network.
Is there a better way to manage globals directly from our Java application?
Comments
See the Native SDK for Java - here are the specific Docs for manipulating Globals as you asked (but the API provides other access types).
There are some related Open Exchange apps - native-api-command-line-java by @Robert Cemper and native-api-contest-template by @Bob Kuszewski you can also use as samples.
But this question is Caché 2016 at its10th birthday ! Not IRIS 2015.*
You can manage globals from a remote Java application by using the InterSystems Native API for Java. This API allows Java applications to connect to a remote InterSystems Caché or IRIS instance and directly access globals without requiring the application and database to run on the same machine.
Instead of relying on cacheextreme.jar, you can configure the connection parameters (host, port, namespace, username, and password) and interact with globals using the native API methods. This approach works well for applications deployed in containers or separate servers, as long as the database port is accessible within the network or VPN.
It provides a more flexible architecture and allows your Java service to read and update global nodes efficiently from a remote environment.
Thanks, Ruben. Does the native API allow multiple connections per process? In my case, I have more than one Cache connection.
Way back in 2020 I wrote an example of how to run COS over ODBC/JDBC
Works of course for any ^Global manipulations
ObjectScript-Over-ODBC-
Thank you for your response. Are the procedures you used also available through SQL access? I wasn’t able to find them.
ClassMethods can be projected to SQL as Procedures.
That's what I used in the only class (ISOS.cls) of this package
The package was written for IRIS but worked in Caché as well for ages..
Thanks, Robert. Could you please explain it in more detail? I’m just a beginner when it comes to globals and this kind of stuff.
same situation for Caché and IRIS
- in the package you install class
zrcc.EX.ISOS.cls - class method ##class(zrcc.EX.ISOS).Gset(....) shows up
- as SQL procedure zrcc_EX.Gset(....)
inside the classmethod it is all standard COS/ISOS
similar;
- ##class(zrcc.EX.ISOS).Xcmd(....) >>> zrcc_EX.Xcmd( ...)
Of course: Working with Globals requires experience in COS/ISOS
From your initial question, I understood that you have SQL access over ODBC
so this article might show a workaround: Get your code over ODBC/JDBC
You are free to formulate whatever you want to achieve.