File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Passing an object from one server to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing an object from one server to another" Watch "Passing an object from one server to another" New topic

Passing an object from one server to another

Nittin singla

Joined: Jul 02, 2011
Posts: 24
What shall be done to pass one object from one server to another. Suppose i have an application distributed over multiple servers. On one server i am creating account and on the other handling the transactions with respect to the account. Now i want to send account object to the other server handling the transactions. How can i do that?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

how about sharing a common DB/File?
Nittin singla

Joined: Jul 02, 2011
Posts: 24
See, the table used to store the account object wont be existing on the other server. That will only be having some transaction related tables that need some of the fields from the account object..So sharing the Db file wont help.

I am thinking of serialization as the best answer .. Means i will serialize an object at the first server then deserialize it while required at the other.. Is there any other better solution possible to it?
Tim Moores

Joined: Sep 21, 2011
Posts: 2414
How about a RESTful web service?
Gupta Tarun

Joined: Sep 16, 2010
Posts: 22

I think you need to be more precise in asking this question - if I understood it correctly, there can be either of following two possibilities :

1. When an account object is created (or any other event happens ) on Server1 you want to notify server2 with that event and pass the data ?
2. Server1 and Server2 just want to share some Data, Assuming both the servers have the appropriate handle for that data (Identifier/primary key etc are available to both the servers.)

if Case 2 is correct then I think its simplest to share using the database/file.

If Case 1 is correct its slightly more work to be done, you will need to use messaging(JMS) or Remoting (EJB / RMI/ Webservices / plain socket communication) technologies depending on whether you want a push mechanism or pull mechanism. Simple File/DB polling is also an option. You should also consider the scenario the event is generated but receiver server is down.
I agree. Here's the link:
subject: Passing an object from one server to another
jQuery in Action, 3rd edition