All Projects → tuhrig → Review_System_Demo

tuhrig / Review_System_Demo

Licence: other
A Spring Boot and AngularJS boilerplate project.

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to Review System Demo

messaging-replication
eXist-db JMS based messaging and document replication extension (JMS based)
Stars: ✭ 14 (-22.22%)
Mutual labels:  jms, activemq
spring-projects
Some spring sample projects
Stars: ✭ 24 (+33.33%)
Mutual labels:  jms, activemq
learning-dome-code
分享日常java学习代码及用例,包括主流的框架、常用的组件、以及比较好的解决方案,项目会持续更新……
Stars: ✭ 58 (+222.22%)
Mutual labels:  jms, activemq
event-driven-microservices
No description or website provided.
Stars: ✭ 15 (-16.67%)
Mutual labels:  jms, activemq
proxy-scraper
⭐️ A proxy scraper made using Protractor | Proxy list Updates every three hour 🔥
Stars: ✭ 201 (+1016.67%)
Mutual labels:  protractor
reactive-jms
Reactive JMS wrapper
Stars: ✭ 16 (-11.11%)
Mutual labels:  jms
Jasmine Spec Reporter
Real time console spec reporter for jasmine testing framework
Stars: ✭ 241 (+1238.89%)
Mutual labels:  protractor
Protractor Cucumber Framework
Cucumber framework plugin for Protractor
Stars: ✭ 191 (+961.11%)
Mutual labels:  protractor
meazure
Screen magnification, measurement, capture and color sampling for Windows.
Stars: ✭ 55 (+205.56%)
Mutual labels:  protractor
activemq-nms-api
Mirror of Apache ActiveMQ NMS API
Stars: ✭ 30 (+66.67%)
Mutual labels:  activemq
qpid-jms
Mirror of Apache Qpid JMS
Stars: ✭ 60 (+233.33%)
Mutual labels:  jms
database-journal
Databases: Concepts, commands, codes, interview questions and more...
Stars: ✭ 50 (+177.78%)
Mutual labels:  activemq
TradingMachine
TradingMachine is a mini-trading system simulation, whose components (market data and order feeds, FIX acceptor and initiator, back-end for filled orders) interact by queues and topics.
Stars: ✭ 26 (+44.44%)
Mutual labels:  jms
jmsScala
JMS for Scala
Stars: ✭ 19 (+5.56%)
Mutual labels:  jms
Ng Pokedex
🐵 Pokedex progressive web app built with Angular
Stars: ✭ 245 (+1261.11%)
Mutual labels:  protractor
spring-boot-web-application-sample
Real World Spring Boot Web Application Example with tons of ready to use features
Stars: ✭ 143 (+694.44%)
Mutual labels:  jms
Protractor Cucumber Typescript
e2e kickstarter test framework which consists of protractor, cucumber frameworks using typescript lang!
Stars: ✭ 194 (+977.78%)
Mutual labels:  protractor
protractor-flake
Rerun potentially flakey protractor tests before failing.
Stars: ✭ 82 (+355.56%)
Mutual labels:  protractor
activemq-website
Apache ActiveMQ Website
Stars: ✭ 16 (-11.11%)
Mutual labels:  activemq
protractor-element-extend
Module, that helps you to extend ElementFinder in your own custom fragments
Stars: ✭ 22 (+22.22%)
Mutual labels:  protractor

Review System Demo

A Spring-Boot and AngularJS boilerplate project

Build Status

About

This is a boilerplate project to show a message driven architecture for Spring Boot projects. Note that this application is highly opinionated and might not fit to your needs or preferences.

Read more: http://tuhrig.de/spring-boot-boilerplate-project-with-activemq-and-angularjs

Tags

Spring Boot, AngularJS, Domain Driven Design, Lombok, ActiveMQ

Use cases of the demo

  • An user can submit a review about a product.
  • Each review will be checked and approved (or rejected).
  • All approved reviews can be listed.
  • Statistics about how many reviews have been submitted, approved and rejected can be seen.

Systems

User Interface System (port 9002)

  • AngularJS based user interface
  • Allows to submit and read reviews and view some overall statistics
  • The backend is a Zuul proxy which forwards requests (to the review system)

Review System (port 9001)

  • Takes and persists all reviews
  • Throws NEW REVIEW events to inform other system about new reviews
  • Listens for APPROVED REVIEW events and REJECTED REVIEW events

Checking System (port 9000)

  • Checks incoming reviews to either approve or reject them
  • Listens for NEW REVIEW events
  • Throws APPROVED REVIEW events or REJECTED REVIEW events

Statistics System (port 9003)

  • Listens for NEW REVIEW, APPROVED REVIEW and REJECTED REVIEW event
  • Provides simple statistics on how many reviews have been submitted, approved or rejected

Run

Perquisites:

  • Java must be installed
  • docker and docker-compose must be installed

Run it:

docker-compose up
./gradlew bootrun --parallel --max-workers=4

Or:

./gradlew review_system:bootrun
./gradlew statistics_system:bootrun
./gradlew checking_system:bootrun
./gradlew user_interface_system:bootrun   

Go to: http://localhost:9002

For development:

Test

Java Tests

./gradlew check

JavaScript Tests

cd User_Interface_System/
grunt check

(Protractor) E2E-Tests

cd E2E_Tests/
grunt protractor

Note: In order to run the E2E tests, all four systems (review, statistics, checking and UI) must be running. The E2E tests will then open a Chrome browser to navigate on the web application.

Developer Notes

Packages

The package structure follows the Ports-And-Adapters pattern.

Domain IDs

Domain IDs identify entities. They are unique business keys and should have a meaningful structure (not just database increments).

Annotations:

  • @Value as its immutable

Example: ReviewId.java

Domain Entities

A domain entity contains actual business functionality. Every domain entity is identified by its ID (not by its current data or state).

Annotations:

  • @Builder to be able to build the entity when loading it from the database
  • @AllArgsConstructor(access = AccessLevel.PRIVATE) to enable the builder
  • @Getter to map the entity to REST resources
  • @Slf4j to log when executing business functionality
  • @EqualsAndHashCode(of = "myEntityId") to enforce equality based on the entity ID

Rules:

  • The only place to implement business logic
  • Should be free of any framework dependency
  • No JPA or Jackson annotations

Example: Review.java

Domain Events

A message send to the world which informs about some event that has happened in the past.

Annotations:

  • @Data as the events are simple containers to exchange information

Rules:

  • No logic, just simple POJOs to hold data
  • Try to use only simple types (e.g. String, int, boolean) to guarantee easy serialisation

Example: ReviewSubmittedEvent.java

REST Resources

Annotations:

  • @Data for simple containers to exchange information

Rules:

  • No logic
  • Use simple types (e.g. String, int, boolean) to guarantee easy serialisation
  • Only use in REST layer

Example: ReviewResource.java

JPA Entities

Annotations:

  • @Data for simple data containers
  • @Entity(name = "MY_TABLE_NAME") to enable JPA on this entity
  • @EntityListeners(AuditingEntityListener.class) to enable auditing (created and last modified date)

Rules:

  • No logic
  • Use simple types (e.g. String, int, boolean) to have no dependencies outside
  • Only use in database layer
  • An entity mapper class to convert to and from the domain layer

Example: ReviewEntity.java

Event Listeners

I've implemented two different types of event listeners. Both solutions have their own pros and cons.

Type 1: JMS based listeners

@Component
public class ReviewSubmittedEventListener {

    @JmsListener(
            destination = "Consumer.statistics_system.VirtualTopic.Events",
            selector = "_type = 'ReviewSubmittedEvent'"
    )
    public void onEvent(ReviewSubmittedEvent event) {
        // pass the event to the service layer
    }
}

Rules:

  • No logic. Just take the event and pass it to a service
  • Use of Spring's @JmsListener annotation

Example: ReviewSubmittedEventListener.java

Type 2: Database based listeners

@Component
public class ReviewApprovedEventListener extends MessageHandler<ReviewApprovedEvent> {

    @Override
    public void onMessage(ReviewApprovedEvent reviewApprovedEvent) {
        // pass the event to the service layer
    }
}

Rules:

  • No logic. Just take the event and pass it to a service
  • Extend the custom MessageHandler class which polls a database table for events

Example: ReviewApprovedEventListener.java

Domain Object Mapper

Whenever we map between the domain layer and any other layer (e.g. persistence, REST) we use a dedicated mapper to do so. Although it's not needed, every mapper should implement the DomainObjectMapper.java interface. By implementing this interface, the concept of a dedicated mapper class is underlined and every mapper follows the same structure.

Rules:

  • Don't map in-place - write a mapper object
  • Implement the DomainObjectMapper.java interface to underline the concept
  • Accept null and simply return null

Example: MessageEntityMapper.java

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].