Jay Ebhomenye
Jay Ebhomenye

Reputation: 1

GridGain Serialization issues

I've created a messaging system using GridGain for implementation. I have a MessageCenter class that is composed of a GridGain GridProjection,my setup looks like something like this

Gateway-> MessageCenter-> GridProjection

Now when I start up the gateway which in turn startup the grid, starting up another gateway I get serialization errors because GridGain is trying to serialize the Gateway, MessageCenter and all their dependencies which forces me to mark everything as Serializable.

I don't understand why GridGain is trying to serialize its parent classes which should have nothing to do with the grid and is their a way to turn it off?

Upvotes: 0

Views: 264

Answers (2)

Jay Ebhomenye
Jay Ebhomenye

Reputation: 1

My fault. I found the problem by switching to Hazelcast. I have a messenger class which both has a receive method and can registers a listener. The messenger resides in a queue in the grid cluster (GridGain or Hazelcast). This requires the messenger to be serializable which in turn means any registered listener also has to be serializable.

My Gateway has runnable handlers which get registered with messengers to handle incoming messages Hence the reverse serialization.

I was unable to find this out with GridGain because GridGain does serialization upfront when a new member joins the grid and tries to serialize everything reachable from objects in its queues, Hazelcast on the other hand does not serialize until runtime

Upvotes: 0

Alexey
Alexey

Reputation: 406

From the description provided it looks like you are sending an anonymous closure/message to the remote node.

Anonymous classes implicitly capture a reference to the enclosing class which forces GridGain to serialize it. The clean solution here is to move your anonymous closure/message to a static inner class. This way you will have full control of what being serialized.

Upvotes: 1

Related Questions