Communication between JVM

Today I was asked this question about the exchange of data from stream t1, which runs in one jvm 1, to stream 2, running in another jvm 2, and similarly to another thread t3 in jvm 3. after some homework, I said the following answer.kindly let me know if you have a better and effective answer.

  • Serialization
  • java nio stream
------------- ----------------- jvm 1 PASS THE DATA TO ANOTHER THREAD IN A JVM2 NOTHER JVM ===============>>>>> tHREAD T1 tHREAD T2 -------------- ------------------- 
+6
java jvm
source share
1 answer

I think it depends on the context of your application. You have several options:

  • Serialization may work, but will likely break if your code changes. This may result in data loss.
  • To exchange data between multiple applications, you can use a database. This is one of the best options in my opinion, since your data will be structured.
  • Alternatively, you can use a formatted text file. Just choose how you want to format the data, put it in a file, and then read the file from another application.
  • If your JVM is on different computers, you can try using sockets. Thus, your applications will be able to communicate over the network.
  • If you have a server acting as a relay for your objects, you can also use the messaging server (I think of JMS).
+11
source share

All Articles