Skip to content

sheronfdo/TrafficManagementSystem

Repository files navigation

Traffic Management System

Overview

The Traffic Management System is an enterprise-level application designed to optimize urban traffic flow by collecting and analyzing real-time data from IoT devices and traffic lights. It leverages Java EE technologies to provide a scalable, modular, and efficient solution for monitoring vehicle speeds, analyzing traffic patterns, and dynamically generating route attributes. The system integrates multiple components, including an EJB application server, a web application server, a MySQL database, and a RabbitMQ message broker for asynchronous communication.

This repository contains the core components of the Traffic Management System, including the EJB application server, web application server, and database configurations. The IoT device simulator is maintained in a separate repository: TrafficManagementSystemIotDeviceSimulator.

Purpose

The system aims to:

  • Monitor Traffic: Collect real-time data on vehicle locations, speeds, and traffic light statuses.
  • Analyze Traffic Flow: Calculate average vehicle speeds and analyze traffic patterns to optimize signal timings.
  • Generate Route Attributes: Provide dynamic route suggestions based on traffic conditions.
  • Enhance Scalability: Use a modular architecture with enterprise technologies for efficient resource management.

System Architecture

The Traffic Management System is built using a distributed, modular architecture with the following components:

  1. EJB Application Server:

    • Centralized server using the Enterprise JavaBeans (EJB) framework.
    • Handles core logic, including:
      • Registering and managing IoT devices and traffic lights.
      • Collecting IoT device locations and speeds.
      • Calculating average vehicle speeds and analyzing traffic flow.
      • Generating route attributes for navigation.
    • Communicates with other components via Remote Method Invocation (RMI).
  2. Web Application Server:

    • Servlet-based server that communicates with the EJB server via RMI.
    • Displays analyzed traffic data, including:
      • Average vehicle speeds.
      • Traffic flow details.
      • Route attributes visualized on a map.
  3. Database Server:

    • MySQL database for storing traffic light statuses and IoT device locations.
    • Integrated with the EJB server using Hibernate for ORM.
  4. RabbitMQ Message Broker:

    • Acts as an alternative to Java Message Service (JMS) for asynchronous communication.
    • Manages a queue (IotLocationData) for updating IoT device locations between the IoT simulator and the EJB server.
  5. IoT Device Simulator (Separate Repository):

    • A Java SE application simulating IoT devices and traffic light statuses.
    • Communicates with the EJB server via RMI and RabbitMQ.

Technologies Used

  • Java EE: EJB (Stateless and Singleton Session Beans), Servlets, JNDI.
  • RabbitMQ: Message broker for asynchronous IoT location updates.
  • MySQL: Database for persistent storage.
  • Hibernate: ORM for database interactions.
  • RMI: For communication between components.
  • Maven: Build tool for dependency management.

Key Components

EJB Components

  • IotDeviceBean (Stateless Session Bean):
    • Manages IoT device registration and location/speed data collection.
    • Uses @Remote interface for RMI.
  • TrafficLightBean (Stateless Session Bean):
    • Handles traffic light location registration and status collection.
    • Uses @Remote interface for RMI.
  • TrafficDataBean (Stateless Session Bean):
    • Calculates average vehicle speeds, analyzes traffic flow, and generates route attributes.
    • Uses @Remote interface for RMI.
  • IotLocationListener (Singleton Session Bean):
    • Uses @Startup and @PostConstruct to initialize a RabbitMQ listener for IoT location updates.
    • Communicates with IotDeviceBean to process location data.

Web Application

  • Servlet-based interface to display traffic data and route attributes.
  • Requests data from TrafficDataBean via RMI.

Database Schema

  • Stores IoT device information (IotDeviceInfo), locations (IotDeviceLocation), traffic light details (TrafficLight), and statuses (TrafficLightStatus).
  • Configured via Hibernate (hibernate.cfg.xml).

Setup Instructions

Prerequisites

  • Java 8 or higher
  • Maven
  • MySQL Server
  • RabbitMQ Server
  • Application Server (e.g., WildFly or GlassFish) for EJB deployment
  • Web Server (e.g., Tomcat) for the web application

Installation

  1. Clone the Repository:

    git clone https://github.com/sheronfdo/TrafficManagementSystem.git
    cd TrafficManagementSystem
  2. Set Up MySQL Database:

    • Create a database named traffic_management_system.

    • Update the Hibernate configuration (hibernate.cfg.xml) with your MySQL credentials:

      <property name="connection.url">jdbc:mysql://localhost:3306/traffic_management_system?useSSL=false</property>
      <property name="connection.username">your_username</property>
      <property name="connection.password">your_password</property>
  3. Configure RabbitMQ:

    • Install and start RabbitMQ server.
    • Ensure the IotLocationData queue is accessible on localhost.
  4. Build the Project:

    mvn clean install
  5. Deploy the EJB Application:

    • Deploy the generated .ear file to an EJB-compatible application server (e.g., WildFly).
  6. Deploy the Web Application:

    • Deploy the generated .war file to a servlet container (e.g., Tomcat).
  7. Run the IoT Device Simulator:

  8. Start the Application:

    • Ensure all servers (MySQL, RabbitMQ, EJB, and web) are running.
    • Access the web interface via the configured URL (e.g., http://localhost:8080/TrafficManagementSystem).

Usage

  1. IoT Device Simulation:

    • The IoT simulator (from the separate repository) generates mock IoT device locations and traffic light statuses.
    • Data is sent to the IotLocationData RabbitMQ queue and processed by IotLocationListener.
  2. Traffic Monitoring:

    • The EJB server collects and processes IoT data, calculating average vehicle speeds and traffic flow metrics.
    • Data is stored in the MySQL database.
  3. Web Interface:

    • Access the web application to view:
      • Real-time traffic flow analysis.
      • Average vehicle speeds.
      • Route attributes displayed on a map.

Scalability and Features

  • Modular Design: Uses EJB containers for transaction management, concurrency, and scalability.
  • Asynchronous Processing: RabbitMQ ensures efficient handling of high-volume IoT location updates.
  • Connection Pooling: Hibernate manages database connections for performance.
  • Distributed Computing: EJB supports deployment across multiple servers for fault tolerance.

Contributing

Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request with your changes.

License

This project is licensed under the MIT License.

Contact

For questions or feedback, contact sheronfdo.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages