BluePrint - Trending Topic Campaigns: Query/Read (Aggregate) Campaign Data
This project is a Domain Specific extension of the Activiti Cloud Query Service. This service provides easy and aggregated access across data generated by different Runtime Bundles (Campaigns).
This project provides a mapping between the data generated by the execution of Business Processes and your domain entities, in this case, the filtered set of Tweets that had matched this campaign.
In order to aggregate data from different Campaigns it uses Spring Cloud Streams (and it is configured to work with RabbitMQ) to listen to events generated by each campaign and store all the data into a selected storage. Depending the amount of data and the shape of the data, a SQL or NoSQL storage can be used.
This project implements the Read part of the CQRS pattern.
Run
In order to run this project locally, you need to clone the source code and then run inside the root directory
mvn -Dserver.port=808x spring-boot:run
Note: replace "x" for your desired port number
You can use the following docker-compose file in order to start Rabbit MQ so the service can connect and send messages.
Endpoints
- GET http://localhost:808x/ -> welcome message
- GET http://localhost:808x/processed/{campaignName} -> get the feed of tweets that had been processed by this campaign
- GET http://localhost:808x/v1/process-instances/ -> get all process instances
- GET http://localhost:808x/v1/tasks/ -> get all created tasks (currently not being used for this example)
Processed Tweet Feed Format
{
"_embedded": {
"tweets": [
{
"text": "Yeah we all shine on, like the moon, and the stars, and the sun.…Also Activiti Cloud is great!",
"author": "JohnLennon",
"lang": "en",
"attitude": "positive",
"timestamp": 1528270266321
},
{
"text": "I destroy my enemies when I make them my friends.… And how good is Activiti Cloud looking?",
"author": "AbrahamLincoln",
"lang": "en",
"attitude": "neutral",
"timestamp": 1528270267325
}
]
},
"_links": {
"self": {
"href": "http://localhost:8090/processed/activiti?page=0&size=100"
}
},
"page": {
"size": 100,
"totalElements": 6,
"totalPages": 1,
"number": 0
}
}
Configuration
This service by default is configured to store data into an in memory DB H2. This can be changed by:
- Uncommenting the PostgreSQL JDBC driver into the pom.xml file and setting H2 to scope test
- Uncommenting the lines inside the application.properties under the comment # PostgreSQL