Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To save the object data

 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application that i am working on does not have a database it does all the works by using the services available. Now we came across a problem. One of the service that we use could fail sometimes(even after retrying) which leads to loss of data that we are supposed to send to that service.

One solution that i know is to use serialization and resend data at later point in time. The problem is, what if the machine at which our application running fails(goes down). The serialized object would be lost.

Can anyone suggest an alternative to save the data.Alternative to save the data or alternative to save the serialized object
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could serialize to files. If your machine goes down objects can be created using those
serialized objects in the files when it's running back up again.

One caveat but, if you deploy a different version of the classes and try to deserialize
objects from a different version you may run in to trouble.

Also how about saving the information to flat files, or xml?
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
serilization and deserialization should be done on a same version of JVM
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am much worried about the situation wherein the machine in which the app is deployed crashes. In that case the serialized objects will also be lost.
(Please keep in mind that i dont have the a DB to store the data)
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have no way to persistently store objects (you don't have a database as you say, or you don't have a file system where you can store the serialized objects in a file), then there is no way you can save the data if the application crashes.

Serialization is not some magic way of storing your objects in case you don't have a place to store them persistently; it's just a mechanism to convert objects to and from a format that's suitable for storing them somewhere.

To solve this problem, you need some kind of persistent store, whether it's a database, a file system or something else.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper Young wrote:To solve this problem, you need some kind of persistent store, whether it's a database, a file system or something else.

Thanks for this strong statement that would never make me think of another alternative which having a way to store (DB or file system)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic