• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JVM to JVM Communication

 
NamrataS Sinha
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am very new to Java Ranch. So please pardon me if there is any mistake in asking or selecting topic.
I am trying to find out the most efficient way for communication between two JVM. I know that determining best suitable method is selected as per the requirement.
In my case I want to allow two JVMs of Core Java app(Stand-alone/ non-enterprise app) to communicate.
For standalone apps I found the below methods :
1. Socket programming.
2. RMI
3. Sharing Files (File IO/ Serializing)
Is there any other method available for stand-alone apps in Java?

Please help me for judging the correct method.
Quick response will be appreciated..


 
Tim Moores
Bartender
Posts: 2856
46
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • a shared DB
  • web services (arguably a higher form of socket comm.)
  •  
    Ram Narayan.M
    Ranch Hand
    Posts: 247
    Chrome Eclipse IDE Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If simply want two JVMs to be communicated, RMI is the best option.

    "Socket Programming" is a raw mode which has to be dealt very carefully.

     
    William Brogden
    Author and all-around good cowpoke
    Rancher
    Posts: 13064
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Another high level communication approach is JMS Java Message Service - which requires a separate JMS server but has the great advantage of being asynchronous.

    Direct socket programming / RMI and web services require that both JVMs work together.

    Shared DB, shared file, JMS permit one JVM to drop off information which the other can pick up as it is convenient.



    Given that Java was developed by a company whose slogan was "the network is the computer" it is not surprising to find so many communication methods.

    Bill
     
    Bhanuprakash Sreenivas
    Greenhorn
    Posts: 8
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    You need to be more specific about your needs.
    Like if it is a critical application , JMS would be a good choice.

    Other options,

    1. Avoid serialization since it will have compatibility issues .
    One lightweight alternative you can explore is Google Protocol Buffers.

    2 . Using a JMS should be an ideal choice based on how robust you want your applications to be.
    But you need to keep in mind the following.
    - Heavyweight , since it will be yet another process inbetween the two JVM process
    - Need to use transactions to make it perfect.

    3 . Expose as a webservice .
     
    NamrataS Sinha
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Tim Moores wrote:
  • a shared DB
  • web services (arguably a higher form of socket comm.)


  • Hi Tim,

    Thanks for the reply.
    Web services requires an application/web server. But, Mine is a Core Java application.
    I don't know much about shared DB. Please refer some Links wherein I can find the efficiency of this method.


    Regards,
    Namrata
     
    NamrataS Sinha
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ram Narayan.M wrote:If simply want two JVMs to be communicated, RMI is the best option.

    "Socket Programming" is a raw mode which has to be dealt very carefully.



    Hi,

    Thanks for the reply.
    Yes , socket programming is very raw form of communication in comparision with RMI.
    But as my question is which method is the efficient one?
    Please suggest.

    Regards,
    Namrata Sinha
     
    NamrataS Sinha
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    William Brogden wrote:Another high level communication approach is JMS Java Message Service - which requires a separate JMS server but has the great advantage of being asynchronous.

    Direct socket programming / RMI and web services require that both JVMs work together.

    Shared DB, shared file, JMS permit one JVM to drop off information which the other can pick up as it is convenient.



    Given that Java was developed by a company whose slogan was "the network is the computer" it is not surprising to find so many communication methods.

    Bill



    Hi Bill,

    Thanks a lot for your reply.
    My application is a Core Java application. Is JMS suitable for it? I mean the JMS reuires a JMS server which is a part of EE server. Then is it suitable for my app?

    I also didn't understand the below line :-
    Direct socket programming / RMI and web services require that both JVMs work together. Please elaborate..

    Yes Java has lots of method of communication between JVM to JVM. But, I want the method that runs for Core Java app . So please suggest such methods.


    Regards,
    Namrata
     
    NamrataS Sinha
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bhanuprakash Sreenivas wrote:
    You need to be more specific about your needs.
    Like if it is a critical application , JMS would be a good choice.

    Other options,

    1. Avoid serialization since it will have compatibility issues .
    One lightweight alternative you can explore is Google Protocol Buffers.

    2 . Using a JMS should be an ideal choice based on how robust you want your applications to be.
    But you need to keep in mind the following.
    - Heavyweight , since it will be yet another process inbetween the two JVM process
    - Need to use transactions to make it perfect.

    3 . Expose as a webservice .


    Hi,

    Thanks for your reply.

    Yes my application is a critical one. But can JMS be used for a stand-alone application? Please give me some reference that gives example of running JMS for non-enterprise applications.

    Again web -services doesn't seem the solution.
    Please suggest.

    Regards,
    Namrata Sinha

     
    William Brogden
    Author and all-around good cowpoke
    Rancher
    Posts: 13064
    6
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    1. You don't need to buy into the full JEE to get a JMS server - see the Apache ActiveMQ project and many other open source implementations.

    2. An important distinction.
    I also didn't understand the below line :-
    Direct socket programming / RMI and web services require that both JVMs work together. Please elaborate..


    For direct socket, etc. both JVMs must be devoting CPU cycles at the same time. A transmitting socket MUST have an active receiving socket. etc.

    Socket to socket will always be the fastest - harder to write or alter, harder to debug, but fastest.

    Bill
     
    NamrataS Sinha
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    William Brogden wrote:1. You don't need to buy into the full JEE to get a JMS server - see the Apache ActiveMQ project and many other open source implementations.

    2. An important distinction.
    I also didn't understand the below line :-
    Direct socket programming / RMI and web services require that both JVMs work together. Please elaborate..


    For direct socket, etc. both JVMs must be devoting CPU cycles at the same time. A transmitting socket MUST have an active receiving socket. etc.

    Socket to socket will always be the fastest - harder to write or alter, harder to debug, but fastest.

    Bill


    Hi Bill,

    Thanks a lot for such a comprehensive reply.
    It is very much helpful.



    Regards,
    Namrata Sinha
     
    Jimmy Clark
    Ranch Hand
    Posts: 2187
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    A web service is used to connect distributed applications. This is the modern method of distributed computing and does not require an application server or a web server. See Axis for more details http://ws.apache.org/axis/java/user-guide.html
     
    kien kun
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    RMI,which is called remote computers.
    TCP/UDP Socket is transplanted between more computer in the network
    The Java Message Service (JMS) API is a Java Message Oriented Middleware for sending messages between two or more clients.
    CORBA is a mechanism in software for normalizing the method-call semantics between application objects residing either in the same address space (application) or remote address space (same host, or remote host on a network).
     
    Nicolo Villarete
    Greenhorn
    Posts: 7
    Eclipse IDE Java Redhat
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If it's JVM to JVM I would also go for RMI.
     
    Tim Moores
    Bartender
    Posts: 2856
    46
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The problem with RMI is that it generally relies on both sides using the same JVM version, which is a rather unpractical requirement. I don't understand why anyone would use RMI these days when web services are so easily implemented.
     
    Pat Farrell
    Rancher
    Posts: 4678
    7
    Linux Mac OS X VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Nicolo Villarete wrote:If it's JVM to JVM I would also go for RMI.

    Using RMI usually adds far more problems to any solution. Its a poor solution in general. I have not seen a good use for RMI this century.
     
    Nick Stavros
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Another solution is to use a Object Management Group (OMG) Standard Data Distribution Serves (DDS). See the wikipedia entry for DDS: Data Distribution Service (DDS)

    I like this solution because:

  • It is a standard based solution that standardized the APIs as well as the data format for marshaling the data
  • It can be used within the same box or across different boxes just by changing the configuration
  • It is a many-to-many publish-subscribe paradigm
  • It is scalable to many publishers and subscribers
  • It can be configured for durability )i.e., store data to a DB
  • It can be configured to reliable deliver messages allowing asynchronous publish-subscribe
  • There are over a dozen vendors including open source providers that have demonstrated interoperability between themselves
  • It works on multiple hosts OSs (UNIX, Linux, Windows)
  • It works with numerous languages (Java, C/C++, C#, etc) so it can be used to connect differed codebases
  • There is a developing standard (i.e., summer of 2013) for support of RESTful interfaces
  • There is support for Microsoft Office including Excel, PowerPoint) which allows you to use the published data from within these products too.
  • It is extremely fast and can support real-time solutions (i.e., 100,000+ messages a second)
  • You simply link in a .so or .dll to your code on each publisher and subscriber ... NO SERVERS REQUIRED

  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic