Skip to content

Monitor a database table and notify all the browsers with a session established every time the contents of the table change.

Notifications You must be signed in to change notification settings

sasaen/action-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

action-monitor

Action-monitor test implementation using Tomcat, Rest endpoints, WebSockets, ActiveMQ and HSQLDB within Spring.

Requirements:

  • Java 8
  • Maven 3.3.9
  • Spring 4.3.4

Instructions to use:

  • Download the code from https://github.com/sasaen/action-monitor
  • Run it by opening a terminal, cd to the downloaded folder and type: mvn spring-boot:run
  • Open http://localhost:8080 in a web browser.
  • Click on "Connect" to create a WebSocket connection.
  • An HSQL DB Swing utility will be open automatically. This utility will allow easy access/manipulation of the USERS table. The execution of UPDATE, DELETE or INSERT on the table will be notified to WebSocket clients.

Notes:

  • I have used windows to develop and test the application.
  • For simplicity Tomcat, ActiveMQ and HSQLDB run in the same JVM. In production ActiveMQ and HSQLDB would run in independent processes. In that case the database listener would need to be in ActiveMQ's classpath and should be a JMS client (I did not try though). On internet I found that Oracle and PostgreSQL databases allow to register a listener using JDBC, no need to run in the same JVM.
  • The server name is set to localhost in src\main\resources\static\app.js.
  • As for the rest endpoints, I was not sure what the goal was here so I made 2 assumptions. Let me know if they don't meet the expectations:
  • There is room for improvement in the browser client, for example the WebSocket could be connected on page-load and disconnected on page-closed or session expiration.
  • I added some unit tests but I did not have time to complete them properly.
  • The tests fail if they are run all together, I need to fix this. However if they are run independently they pass.
    • mvn -Dtest=com.sasaen.monitor.rest.* test
    • mvn -Dtest=com.sasaen.monitor.websocket.* test
    • mvn -Dtest=com.sasaen.monitor.jms.* test
    • mvn -Dtest=com.sasaen.monitor.* test
  • I added an integration test for the flow DatabaseTrigger-->JMS Client-->ActiveMQ-->JMSListener-->WebSocketController.

TODO:

  • Make sure the application works with different browsers and from different machines and OS (Linux/Android). I will complete this over the week.
  • Complete tests and get them running in the same test suite: mvn test
  • Check the JMSTemplate is being built properly to avoid this: http://activemq.apache.org/jmstemplate-gotchas.html

About

Monitor a database table and notify all the browsers with a session established every time the contents of the table change.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published