ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guilherme Melo <guilhe...@gmelo.org>
Subject Using event to reconnect spring created cache client to server
Date Thu, 02 Nov 2017 14:46:29 GMT
Hello all,

am having a issue with reconnection to a spring created ignite cluster,
both instances are wrapped in spring boot 1.5.8.RELEASE and Ignite 1.9

Server:

@Autowired
ApplicationContext context;

@Bean
public Ignite igniteClient() throws IgniteCheckedException {
    IgniteConfiguration configuration = new IgniteConfiguration();
    CacheConfiguration cacheCfg = new CacheConfiguration("myCache");
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    configuration.setCacheConfiguration(cacheCfg);
    return IgniteSpring.start(configuration, context);
}

Client


@Autowired
ApplicationContext context;

@Bean
public Ignite igniteClient() throws IgniteCheckedException {
    IgniteConfiguration configuration = new IgniteConfiguration();
    configuration.setClientMode(true);
    Ignite ignite = IgniteSpring.start(configuration, context);

    ignite.events().localListen(evt -> {
        logger.warn("Event: {}", evt);
        if (EventType.EVT_CLIENT_NODE_RECONNECTED == evt.type()) {
            //to check the ignite instance is fine
            logger.info("All caches: {}", ignite.cacheNames());
            //will hold and eventually throw
            ignite.cache("myCache");
        }
        logger.warn("Event handle end");
        return true;
    }, EventType.EVT_CLIENT_NODE_RECONNECTED,
EventType.EVT_CLIENT_NODE_DISCONNECTED);
    return ignite;
}

is there anything I am missing? something around the dynamic caches? Should
they be created elsewere? Thanks !

Mime
View raw message