In this post, we'll learn how to use Spring Boot with Apache Storm. We'll cover the following topics:
Apache Storm is a free and open source distributed real-time computation system. Storm makes it easy to reliably process unbounded streams of data, doing for real-time processing what Hadoop did for batch processing.
Storm is simple, can be used with any programming language, and is a lot of fun to use!
Spring Boot is a framework for easily creating stand-alone, production-grade Spring-based Applications that you can "just run". We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.
Now that we know what Storm and Spring Boot are, let's see how to use them together.
The first thing we need is a Maven dependency for Storm:
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
We also need a dependency for Spring Boot:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Now we can create a Spring Boot application:
@SpringBootApplication
public class StormApplication {
public static void main(String[] args) {
SpringApplication.run(StormApplication.class, args);
}
}
We can now create a Storm topology in our application:
@Component
public class MyTopology {
@Autowired
private TopologyBuilder topologyBuilder;
@PostConstruct
public void init() {
// ...
}
}
And that's it! We now have a working Storm topology within our Spring Boot application.