Not sure if the title is appropriate, but here is my question
I wrote a class, for example,
version 1
class SomeClass
{
public method1()
{
...
...
}
public method2()
{
...
...
}
}
The objects of SomeClass are pushed to a message queue by different modules say
module1
module2
module3
which then is being processed module4
Now, module3 requires some additional functionality method3() so I added additional functionality to SomeClass
version 2
class SomeClass
{
public method1()
{
...
...
}
public method2()
{
...
...
}
public method3()
{
...
...
}
}
and updated module3 and module 4 with this new class, however module1 and module2 are not
module3 will post objects of SomeClass (version 2) to the message queue, however module1 and module2 still post objects of SomeClass (version 1)
Will there be any problems for module 4 that has version 2 definition to read the objects of version 1 definition?
Theoretically it could work because when you push object to message queue (using
ObjectMessage) it is serialized using standard java serialization mechanism. Serialization does not care about methods. It uses fields only. It means that you can serialize object v1 and then deserialze it using class version 2. But I believe you will have to add special fieldprivate static long serialVersionUIDto your class and manage its value manually.So, your v1 and v2 that have identical number and order of field and differ by methods only will have the same
serialVersionUID.