When the mail server receive email, it would trigger a java program by calling a shell script.
However, as the volumne of email is large, the java program will be triggered serveral times...
Better Design
Have a search in google and found something is useful to improve the current design.
The following is extracted from stackoverflow:
----------------------------------------------------------------------------------------------------
Standalone Java application is already running, so command line parameters are out of question.
Simplest alternatives remaining are polling for files, sockets and HTTP server.
Polling for files:
Make you java app to read a specific directory once in a few seconds. If a file appears in that directory, read it and do as it says. Make your shell script to form that file.
Socket:
Make you java app to listen on a socket. Use netcat or a similar utility to send commands to that socket.
HTTP Server:
Start an HTTP listener within the Java process. Use wget or similar utility to post your commands to that listener:
HttpServer httpServer = HttpServer.create(new InetSocketAddress(port), 5);
httpServer.createContext("/", new TileServerRequestHandler());
httpServer.setExecutor(Executors.newCachedThreadPool());
httpServer.start();
Other options:
JMS
Reference
http://stackoverflow.com/questions/5913400/how-to-communicate-with-existing-java-process
No comments:
Post a Comment