Calling standalone application from java MatlabEngine
Mostra commenti meno recenti
I am developing a microservice that uses Websockets to send data to and from MATLAB functions. On my development machine, I have a jar that opens a socket for listening after starting an Engine instance. When I receive a json message on the socket, it sends this to the engine, along with the state of the session:
WebSocket conn = event.getConn();
String message = event.getMessage();
String attachment = conn.getAttachment();
Object[] output = matlabEngine.feval(2, dispatchCommand, message, attachment);
attachment = (String) output[1];
String result = (String) output[0];
conn.setAttachment(attachment);
conn.send(result);
dispatchCommand is a .m file that processes everything. This runs, and I can launch the jar from the command line (specifying the port), or from a systemd socket service (specifying LD_LIBRARY_PATH as an environment variable).
So now I want to deploy this to a docker container, and I'm trying to figure out how (or if) MATLAB Compiler fits into all of this, or whether all I need to do is use a Docker image with the runtime libraries installed.My thought is to launch the compiled application which reads from and writes to a Unix domain socket, but I don't know if this is any more efficient than matlabEngine.feval.
In either situation, I want the MATLAB process to launch on demand and exit when done. The current implementation starts in about 10 seconds, way less time than it takes the user to enter the data in the form that is sent to the MATLAB routine. While I've written the system to open the Websocket in MATLAB, System.inheritedChannel(); gets clobbered by MATLAB, mazking it impossible to inherit the socket from systemd.
Risposte (1)
Jeff Mandel
il 8 Nov 2025
Categorie
Scopri di più su Java Package Integration in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!