I am trying to execute some code on a member node of an infinispan cluster but I'm getting the same error all the time.
org.infinispan.commons.marshall.NotSerializableException:
The use case is pretty basic. There's a list of units only the coordinator node knows and wants to distribute some work among its member nodes.
Basically I just want to call a method remotely with my args. That's it, that's all, plain and simple.
private void processUnit(Unit unit)
{
Processor.process(unit);
}
public void distributeUnits(List<Unit> units)
{
for (int i = 0; i < units.size(); ++i)
{
Address target = getAddress(i);
ClusterExecutor executor = getExecutor();
executor.filterTargets(target).submit((Runnable & Serializable) () -> processUnit(unit);
}
}
My goal would be the member node to execute the Runnable with the node context (its own Processor, which is an @Autowired spring @Component).
I have tried different approaches like statics here and there, classes extending and/or implementing Runnable, Serializable, etc. Last thing I've tried is to use the Observer pattern to instead of calling the Processor to call a static OBSERVABLE.notifyObservers(unit) (which has the Processor added as observer). But I've got the same output, and at this point its just trial and error. I'm out of ideas and I would appreciate some directions or guidelines on this.