Failed to marshal object When inserting to queue

classic Classic list List threaded Threaded
4 messages Options
Isaeed Mohanna Isaeed Mohanna
Reply | Threaded
Open this post in threaded view
|

Failed to marshal object When inserting to queue

Hi
I have a very simply queue, that is backed by a simple cache object.
I have the following class:
public class MyClass implements Serializable {
    private static final long serialVersionUID...
    private String id;
    private Date time;

    // Setters & Getters
}

When trying to insert a list of MyClass elements into the queue, i get a failed to marshal exception even though my class is Serializable. (Full exception is attached)
exception.txt

Why am i receiving this exception even though my class is Serializable, is there any way around it without disabling the marshaller which could cause performance degradation as i understood?
My Cache configuration:
CacheConfiguration<?, ?> cache= new CacheConfiguration<>();
cache.setName("queueCache");
cache.setCacheMode(CacheMode.REPLICATED);
cache.setAtomicityMode(CacheAtomicityMode.ATOMIC);
My Queue Init:
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCacheName("queueCache");
IgniteQueue<MyClass> queue = ignite.queue("queueCache", 0, colCfg);

 Queue Usage
List<Myclass> queueItems;
// Populate list with some data
queue.addAll(queueItems);

Thanks for your help
Semyon Boikov Semyon Boikov
Reply | Threaded
Open this post in threaded view
|

Re: Failed to marshal object When inserting to queue

Hi,

I can not reproduce this error, could you please provide all your code so that I can run it.
Also looks like exception you attached is not completed: exception cause if missed.

On Mon, Jun 1, 2015 at 10:41 AM, Isaeed Mohanna <[hidden email]> wrote:
Hi
I have a very simply queue, that is backed by a simple cache object.
I have the following class:
public class MyClass implements Serializable {
    private static final long serialVersionUID...
    private String id;
    private Date time;

    // Setters & Getters
}

When trying to insert a list of MyClass elements into the queue, i get a
failed to marshal exception even though my class is Serializable. (Full
exception is attached)
exception.txt
<http://apache-ignite-users.70518.x6.nabble.com/file/n432/exception.txt>

Why am i receiving this exception even though my class is Serializable, is
there any way around it without disabling the marshaller which could cause
performance degradation as i understood?
*My Cache configuration:*
CacheConfiguration<?, ?> cache= new CacheConfiguration<>();
cache.setName("queueCache");
cache.setCacheMode(CacheMode.REPLICATED);
cache.setAtomicityMode(CacheAtomicityMode.ATOMIC);
*My Queue Init:*
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCacheName("queueCache");
IgniteQueue<MyClass> queue = ignite.queue("queueCache", 0, colCfg);

* Queue Usage*
List<Myclass> queueItems;
// Populate list with some data
queue.addAll(queueItems);

Thanks for your help



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Failed-to-marshal-object-When-inserting-to-queue-tp432.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Isaeed Mohanna Isaeed Mohanna
Reply | Threaded
Open this post in threaded view
|

Re: Failed to marshal object When inserting to queue

Hi
I have created a standalone application to reproduce the problem but then i got it to work, i implemented Externalizable interface... it turns out that some older version of the class was used in my setup for some reason.
Deeply sorry for wasting your time... a question thought... what is the difference between implementing serializable vs externalizable to be used with ignite? is there any major difference? should i prefer one over the other?

Thanks

On Mon, Jun 1, 2015 at 12:28 PM, Semyon Boikov <[hidden email]> wrote:
Hi,

I can not reproduce this error, could you please provide all your code so that I can run it.
Also looks like exception you attached is not completed: exception cause if missed.

On Mon, Jun 1, 2015 at 10:41 AM, Isaeed Mohanna <[hidden email]> wrote:
Hi
I have a very simply queue, that is backed by a simple cache object.
I have the following class:
public class MyClass implements Serializable {
    private static final long serialVersionUID...
    private String id;
    private Date time;

    // Setters & Getters
}

When trying to insert a list of MyClass elements into the queue, i get a
failed to marshal exception even though my class is Serializable. (Full
exception is attached)
exception.txt
<http://apache-ignite-users.70518.x6.nabble.com/file/n432/exception.txt>

Why am i receiving this exception even though my class is Serializable, is
there any way around it without disabling the marshaller which could cause
performance degradation as i understood?
*My Cache configuration:*
CacheConfiguration<?, ?> cache= new CacheConfiguration<>();
cache.setName("queueCache");
cache.setCacheMode(CacheMode.REPLICATED);
cache.setAtomicityMode(CacheAtomicityMode.ATOMIC);
*My Queue Init:*
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCacheName("queueCache");
IgniteQueue<MyClass> queue = ignite.queue("queueCache", 0, colCfg);

* Queue Usage*
List<Myclass> queueItems;
// Populate list with some data
queue.addAll(queueItems);

Thanks for your help



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Failed-to-marshal-object-When-inserting-to-queue-tp432.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


yakov yakov
Reply | Threaded
Open this post in threaded view
|

Re: Failed to marshal object When inserting to queue

Externalizable is faster, but less flexible. Externalizable does not allow class mutation, while Serializable does.

I would recommend to go with Externalizable and handle class mutation manually.