ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mshah <mshah.opensou...@gmail.com>
Subject Re: how to configure apache ignite as cache api and as spring cache provider
Date Thu, 13 Sep 2018 12:52:07 GMT
Hi,

Thank you for the response. 

I tried the following configuration as you mentioned

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cache="http://www.springframework.org/schema/cache"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           
http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/cache
         					http://www.springframework.org/schema/cache/spring-cache.xsd"
                            >
                            
    
      
     
    <bean class="org.apache.ignite.configuration.IgniteConfiguration">
      <property name="peerClassLoadingEnabled" value="true"/>
      <property name="igniteInstanceName" value="claimgrid"/>
    <property name="cacheConfiguration">
                    <list>
                        <bean
class="org.apache.ignite.configuration.CacheConfiguration">

                            <property name="name"
value="T_MST_TEUC_Q_PERCENTAGE"/>
                            <property name="cacheMode" value="REPLICATED"/>
                            <property name="atomicityMode" value="ATOMIC"/>
                            <property name="partitionLossPolicy"
value="READ_WRITE_SAFE"/>
                            <property name="backups" value="0"/>
                            <property name="groupName" value="masterData"/>
                            <property name="cacheStoreFactory">
                                <bean
class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
                                    <constructor-arg
value="com.mrm.access.benefits.ms.claim.cache.store.SequesterPercentageModelStore"/>
                                </bean>

                            </property>

                            <property name="readThrough" value="true"/>
                            <property name="writeThrough" value="true"/>
                             
                        </bean>
    </list>
    </property>
    
    
    
        <property name="discoverySpi">
            <bean
class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                     <property name="addresses">
                            <list>  
                                  <value>10.80.211.76</value>
                            </list>
                        </property>
                        </bean>
                </property>
            </bean>
        </property>
    </bean>
    
    
    <bean id="cacheManager"
class="org.apache.ignite.cache.spring.SpringCacheManager">
       	<property name="igniteInstanceName" value="claimgrid" />

    </bean>
    <cache:annotation-driven/>
       
</beans>


Below is the code to start the  spring application and ignite instance


public static void main(String[] args) throws Exception
	{
		ApplicationContext context= SpringApplication.run(Application.class,
args);
		initializeIgnite(context);
		test_cache();
	}

	private static void initializeIgnite(ApplicationContext context) throws
IgniteCheckedException
	{
		logger.debug("Initializing Ignite");
		Ignite ignite=IgniteSpring.start("ignite-config.xml", context);
		logger.debug("Ignite Initialized Successfully");
	}

I am getting the following exception

Exception in thread "main" class
org.apache.ignite.IgniteIllegalStateException: Ignite instance with provided
name doesn't exist. Did you call Ignition.start(..) to start an Ignite
instance? [name=claimgrid]
	at org.apache.ignite.internal.IgnitionEx.grid(IgnitionEx.java:1383)
	at org.apache.ignite.Ignition.ignite(Ignition.java:535)
	at
org.apache.ignite.cache.spring.SpringCacheManager.onApplicationEvent(SpringCacheManager.java:334)
	at
org.apache.ignite.cache.spring.SpringCacheManager.onApplicationEvent(SpringCacheManager.java:146)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:888)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
	at
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:381)
	at
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)
	at
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
	at
org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:744)
	at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:945)
	at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:854)
	at org.apache.ignite.IgniteSpring.start(IgniteSpring.java:90)
	at
com.mrm.access.benefits.ms.claim.Application.initializeIgnite(Application.java:47)
	at com.mrm.access.benefits.ms.claim.Application.main(Application.java:40)





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Mime
View raw message