This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I want two JVMs to communicate with each other. I got some suggestions on this topic, however, I am not absolutely sure what to use. The communication is quite simple, it is one JVM running the web application with Tomcat and one JVM is the backend system calculating some stuff. Now I want to use the web application to invoke the calculation to start on the other JVM. It is quite simple, and there is mere information to exchange.
RMI seems a bit overpowered for this task. The suggesstion was JMS and sockets so far. But on what base should I decide which to use?
What are the requirements? JMS is asynchronous (and implies the existence of a messaging server), while sockets work synchronously - it's hard to picture a scenario where both approaches are equally adequate.
Joined: Sep 20, 2010
Yes, I see the difference. These requirements were not considered yet. Maybe the backend system should run some request which were invoked by the web application.
So, what I say, the possibility is there, that the backend system is running an algorithm, meanwhile the web application sends a new request, which has to be dealt with. This is what I understand to asynchronrous communication, request are invoked even so the backend system is not listening at the moment.
However, I don't see the point how this cannot be realizes with a socket through concurrent execution.
Joined: Mar 22, 2005
The web app could certainly use a socket to shoot the request to the app server, then close the socket after it got some kind of ID from the app server, and finally -some time later, most likely as part of a different request it is serving- re-contact the app server with the ID to find out if the results are in. That would make the communication sort of asynchronous.
Joined: Sep 20, 2010
Okay, I will go for sockets. Do I have to connect/listen the socket to localhost/127.0.0.1 or is there an alternative path suggested?