Context serialization in callables

classic Classic list List threaded Threaded
2 messages Options
vsuslov vsuslov
Reply | Threaded
Open this post in threaded view
|

Context serialization in callables

This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hi, I have a spring project where I need to form an IgniteCallable from my business logic and send to a particular data-node to execute. But in this callable I send a heavy context(lots of @Autowired dao-objects and services that are needed to get/set values from/to the cache while executing the callable, and that are serialized)

Is there a better way?

the only choice I see to change all daos to native get/set requests to cache inside the callable but there are lots of aditional work
---------------
Best regards,
Suslov Vadim
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Context serialization in callables

Hi Vadim,

Please subscribe to the Ignite users mailing list before posting messages here. Otherwise they are not forwarded properly. See the instruction here: http://apache-ignite-users.70518.x6.nabble.com/mailing_list/MailingListOptions.jtp?forum=1

vsuslov wrote
Hi, I have a spring project where I need to form an IgniteCallable from my business logic and send to a particular data-node to execute. But in this callable I send a heavy context(lots of @Autowired dao-objects and services that are needed to get/set values from/to the cache while executing the callable, and that are serialized)

Is there a better way?
Are these DAOs available on all nodes? If yes and you start your nodes with a Spring XML file that contains all required beans, you can inject the application context into the job and use it to get any required beans. The context will be injected on the remote node where the callable is executed, so it can be transient and will never be sent over the network. Here is an example:

public class MyCallable implements IgniteCallable {
    @SpringApplicationContextResource
    private transient ApplicationContext appCtx;

    @Override public Object call() throws Exception {
        MyDao dao = appCtx.getBean("myDao");

        ...
    }
}

-Val