<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Akshay Gadhave</title>
    <description>The latest articles on DEV Community by Akshay Gadhave (@akshay0505).</description>
    <link>https://dev.to/akshay0505</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3171408%2F16f653e4-8d92-4621-9522-9e80918872dc.png</url>
      <title>DEV Community: Akshay Gadhave</title>
      <link>https://dev.to/akshay0505</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akshay0505"/>
    <language>en</language>
    <item>
      <title>Learning Quartz Scheduler with a Real-Time Spring Boot Project</title>
      <dc:creator>Akshay Gadhave</dc:creator>
      <pubDate>Sun, 18 May 2025 19:42:45 +0000</pubDate>
      <link>https://dev.to/akshay0505/learning-quartz-scheduler-with-a-real-time-spring-boot-project-437l</link>
      <guid>https://dev.to/akshay0505/learning-quartz-scheduler-with-a-real-time-spring-boot-project-437l</guid>
      <description>&lt;p&gt;When diving into the world of Java-based job scheduling, &lt;strong&gt;Quartz Scheduler&lt;/strong&gt; stands out as a robust and flexible solution. But beyond basic tutorials, real understanding often comes from building something tangible. In this blog, I’ll walk you through my experience of learning Quartz Scheduler by building a real-time &lt;strong&gt;System Resource Monitoring&lt;/strong&gt; application using &lt;strong&gt;Spring Boot&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What We Built
&lt;/h2&gt;

&lt;p&gt;A lightweight Spring Boot application that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Monitors &lt;strong&gt;CPU&lt;/strong&gt; and &lt;strong&gt;memory&lt;/strong&gt; usage of a Windows machine&lt;/li&gt;
&lt;li&gt;Logs data into a CSV file&lt;/li&gt;
&lt;li&gt;Uses Quartz Scheduler to control monitoring intervals&lt;/li&gt;
&lt;li&gt;Exposes REST APIs to fetch logs, configure schedule, and view system metadata&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This project was built with the intention of understanding Quartz in a practical, useful context.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Quartz Scheduler?
&lt;/h2&gt;

&lt;p&gt;Quartz is a powerful and mature job scheduling library that supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cron-based scheduling&lt;/li&gt;
&lt;li&gt;Simple time-based intervals&lt;/li&gt;
&lt;li&gt;Persistent jobs&lt;/li&gt;
&lt;li&gt;Clustering and more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our case, it was a perfect fit to schedule a recurring monitoring job that logs system resource usage every few seconds.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Java 17&lt;/li&gt;
&lt;li&gt;Spring Boot 3+&lt;/li&gt;
&lt;li&gt;Quartz Scheduler&lt;/li&gt;
&lt;li&gt;OSHI (Operating System &amp;amp; Hardware Info)&lt;/li&gt;
&lt;li&gt;Maven&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Core Features
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/monitor/history?n=10&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get the last N monitoring records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/monitor/download&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Download the monitoring CSV file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/monitor/schedule/start?interval=60&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set schedule interval in seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/monitor/metadata&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;View OS, CPU, RAM info&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each of these endpoints was backed by a clean service layer and a Quartz-triggered job that handled the actual resource capture and file writing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Learning Points
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Job Scheduling
&lt;/h3&gt;

&lt;p&gt;I learned how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Define a job using &lt;code&gt;QuartzJobBean&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Register the job with a &lt;code&gt;SchedulerFactoryBean&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Dynamically reschedule jobs&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  CSV File Logging
&lt;/h3&gt;

&lt;p&gt;Instead of using a database, I wrote logs to a simple CSV file, which helped me focus more on the scheduling mechanics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-time System Monitoring
&lt;/h3&gt;

&lt;p&gt;Using the OSHI library, I captured:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Current CPU load (between ticks)&lt;/li&gt;
&lt;li&gt;Used and total memory&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  REST APIs
&lt;/h3&gt;

&lt;p&gt;I added a controller layer to make the application easily testable and extensible. Through simple GET and POST endpoints, users can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;See logs&lt;/li&gt;
&lt;li&gt;Configure job frequency&lt;/li&gt;
&lt;li&gt;Access system metadata&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Project Setup &amp;amp; Usage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub Repo:&lt;/strong&gt; &lt;a href="https://github.com/akshay-0505/QuartzSystemMonitor" rel="noopener noreferrer"&gt;QuartzSystemMonitor by akshay-0505&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Java 17+&lt;/li&gt;
&lt;li&gt;Maven 3+&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to Run
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Clone the repository&lt;/span&gt;
https://github.com/akshay-0505/QuartzSystemMonitor.git
&lt;span class="nb"&gt;cd &lt;/span&gt;QuartzSystemMonitor

&lt;span class="c"&gt;# Build the project&lt;/span&gt;
mvn clean &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Run the Spring Boot app&lt;/span&gt;
mvn spring-boot:run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Available Endpoints
&lt;/h3&gt;

&lt;p&gt;Visit: &lt;code&gt;http://localhost:8080/api/monitor/...&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;This was just the beginning. The project can be extended with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Database storage and pagination&lt;/li&gt;
&lt;li&gt;Real-time dashboards (e.g., using WebSockets)&lt;/li&gt;
&lt;li&gt;Alerts when usage thresholds are crossed&lt;/li&gt;
&lt;li&gt;Frontend UI with charting libraries&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Learning Quartz with this hands-on project taught me more than just scheduling. It gave me insight into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modular Spring Boot design&lt;/li&gt;
&lt;li&gt;Background job patterns&lt;/li&gt;
&lt;li&gt;Building developer tools that solve real problems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was more than an experiment — it was a stepping stone into backend systems that are &lt;strong&gt;time-sensitive and efficient&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let me know if you want to contribute to the project.&lt;/p&gt;

&lt;p&gt;Happy Learning!&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>github</category>
      <category>java</category>
      <category>scheduler</category>
    </item>
  </channel>
</rss>
