Posts

Showing posts from April, 2023

01.Job Scheduler - Project creation

Image
 Jo b Scheduler - Project Creation This is implementing using two ways. 1.Using @Scheduler annotation. 2.Using Quartz scheduler (In the previous example, we executed scheduled tasks, but at the same time, we could not dynamically set the start time of the job, or pass parameters to it. To solve these problems, you can directly use Quartz.) Quartz dependency is not necessary to implement Scheduler. This has been added for future Quartz project implementation. Using @Scheduler Need to add   @EnableScheduling  to main class. @SpringBootApplication @EnableScheduling public class JobScheduleApplication { public static void main (String[] args) { SpringApplication. run (JobScheduleApplication. class, args) ; } } This is a simple scheduler class. @Component public class SchedulerTest { @Scheduled (cron = "0/5 * * * * ?" ) public void everyFiveSeconds () { System. out .println( "Scheduler Executed.EveryFiveSeconds Scheduler: " + new Date()) ;

Database Migration - Topics

Image
Topics 01.Database Migration - Introduction 02.Database Migration - Flyway Vs Liquibase 

01.Database Migration - Introduction

Image
  Database Migration GitHub Link For Sample Project: https://github.com/LahiruPriyankara/Liquibase https://github.com/LahiruPriyankara/flyway Git වැනි version control system වලදී code changes history එකක maintain වන අතර එම නිසා කවුද ඒ ඒ changes කලේ කොයිකාලේද කලේ වගේ full history එකක් බලාගන්න පුලුවන් . ඒ වගේම database එකටත් කරන වෙනස්කම් track කරලා තියාගන්න ඕනේ වෙනවනම් එකට use වන version control system තිබෙන අතර flyway, liquibase යනු එවැනි version control system දෙකක් වේ . Database schema changes track කරගන තියන open source version control application එකකි .Any changes which we do with data base scheme will be track and save in flywayschamahistory table in flyway and databasechangelog table in liquibase.   Liquibase or flyway  is an open-source database-independent library for tracking, managing and applying database schema changes.   Advantage Database independent Automatic update (When application up, Changes will be automatically applied.) Automatic creati

02.Job Scheduler - Cron Job Time Pattern

Image
   Jo b Scheduler - Cron Job Time Pattern  Now understand the cron pattern(* * * * * *). Guiding Tutorial: https://productresources.collibra.com/docs/collibra/latest/Content/Cron/co_spring-cron.htm   <second>     <minute>     <hour>     <day_of_month>    <month>           <day_of_week> , - * /               , - * /            , - * /          , - * ? / L W             , - * /                   , - * ? / L # 0-59               0-59               0-23                1-31                1-12 JAN-DEC      0-7(where 0 is MON)MON-SUN Position Field Allowed Values Allowed Special characters Examples 1 Second 0-59 , - * / 01) 10 = At 10th second. 02) */10 = every 10 seconds.   2 Minutes 0-59 , - * / 01) 30 = at the 30th minute. 02) */15 = every 15 minutes. 03) 5/10 = every 10 minutes starting at the 5th minute after the hour   3 Hours 0-23 , - * / 01) 10 = at 10 o'clock. 02) 8-10 = at 8,9 and 10 AM. 03) 6,18 = at 6 AM and at 6 PM.   4 Days of Month 1-31

02.Database Migration - Flyway Vs Liquibase

Image
Flyway Vs Liquibase GitHub Link For Sample Project: https://github.com/LahiruPriyankara/Liquibase https://github.com/LahiruPriyankara/flyway Differences between Liquibase and Flyway. Flyway  - Use SQL for defining changes. Liquibase  - Use SQL, XML, JSON, YMAL for defining changes (With Liquibase we can work with database-agnostic languages and easily apply schema changes to different database types).  ---------------------------------------------------------------------------------------------------------------------------- Flyway  - Follow file name conventions (a migration should have a convention of prefixes as V (for versioned), U (for undo), and R (for repeatable). It will be followed by a version number and a separator __(two underscores) followed by a description and a suffix .sql such as V01__Add_New_Column.sql). Liquibase  - changes are managed by one ledger known as a master changelog  (db.changelog-master) which will be defined as including all the migrations.   -----------