Manuel
Manuel

Reputation: 319

Ignite and Spring Boot

How do I use Ignite with Spring Boot? I googled it but without success. Has anyone experience with the combination of Spring Boot and Ignite?

Is that the correct way to run Ignite in with Spring Boot? Apache Ignite Loading Twice with Spring-Boot?

Upvotes: 3

Views: 6097

Answers (4)

Sohan Poonia
Sohan Poonia

Reputation: 146

Use following steps to integrate ignite with spring boot.

1. Add following dependency in POM.xml file
     
<dependency>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-core</artifactId>
        <version>${ignite.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-spring</artifactId>
        <version>${ignite.version}</version>
    </dependency>
    <dependency>
	  <groupId>org.apache.ignite</groupId>
	  <artifactId>ignite-spring-data</artifactId>
	  <version>${ignite.version}</version>
	</dependency>
    <dependency>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-indexing</artifactId>
        <version>${ignite.version}</version>
    </dependency> 
2. Create the Ignite bean instance
    @Bean
	public Ignite igniteInstance() {
   		IgniteConfiguration cfg = new IgniteConfiguration();
        Ignite igniteInst= Ignition.start(cfg);
        return igniteInst;
    }
3. Configure the repository
@RepositoryConfig(cacheName = "cacheName")
public interface RepositoryName extends IgniteRepository<V, K> {
}

4. Autowired the RepositoryName interface which extends the IgniteRepository in service layer

@Component
public class ServiceImpl 
@Autowired
RepositoryName  repositoryName; 
}

5. You can use 5th steps apart from 4th steps to inject the ignite bean in service layer
@Component
public class ServiceImpl {
	@Autowired
	Ignite ignite;
    void abcMethod(){
     IgniteCache<K, V> igniteCache = ignite.cache("CacheName");
    }
}

Upvotes: 0

Nam Nguyễn Khoa
Nam Nguyễn Khoa

Reputation: 31

For me use case, i create a bean and start ignite inside it after that return the ignite. it will start ignite only one time at start time.

Upvotes: 1

Normal
Normal

Reputation: 1377

I've got test project spring boot + ignite. I hope that will help: github project

Upvotes: 2

Valentin Kulichenko
Valentin Kulichenko

Reputation: 8390

Currently there is now direct integration with Spring Boot, so you should manually start a node within the application using Ignition.start() method.

Upvotes: 2

Related Questions