Application demonstrate how to create small Spring application that is listening on Twitter public stream. Application persist tweets in MySQL and ElasticSearch databases and enables user to search tweets from MySQL and ElasticSearch.
This application was created as demo included in presentation.
- Java 1.8
- Maven
- NodeJS
- Bower
- MySQL
- ElasticSearch 1.7.3
In order to be able to read tweets from Twitter API you need to create application on Twitter. Tutorial how can you create Twitter application you can find on this link.
When you have created Twitter application in resource file you need to replace next fields with keys from your application:
- spring.social.twitter.appId
- spring.social.twitter.appSecret
- spring.social.twitter.accessToken
- spring.social.twitter.accessTokenSecret
Paramaters for connecting to MySQL database can be found in resource file:
- spring.datasource.url
- spring.datasource.username
- spring.datasource.password
As you can see from default configuration, in MySQL you have to create database scheme es_demo.
You should setup your ElasticSearch instance to have cluster name: web_app_demo
In order to build application you need to download javascript resources. This can be done with bower by running command in root folder:
bower install
In order to start application you need to run maven command in root folder of application:
mvn spring-boot:run
If you for some reason don't want to install MySQL and ElasticSearch on your machine, you can use supplied docker-compose configuration file.
In order to start MySQL container and ElasticSearch container this need to be done:
- Open terminal in
docker
folder of this project - Start docker-compose with command:
docker-compose up
orsudo docker-compose up
Pay attention that this two containers expect ports 3306, 9200 and 9300 to be free.
elasticsearch-spring-demo is released under MIT License.