Quartz doesn't work properly in cluster environment











up vote
0
down vote

favorite












i am using quartz-2.2.3 on websphere 8.5.5 on a cluster environment where i have 2 nodes and on each node there are 3 JVMS



i am configuring the job on application startup.



ISSUE: the job is getting configured one time on each node, and what i expect is that it will be configured only one time on both nodes not one on each node.



my configuration is as follows :



quartzConfig.properties:



#============================================================================
# Configure Main Scheduler Properties
#============================================================================

org.quartz.scheduler.instanceName = MyJobScheduler
org.quartz.scheduler.instanceId = AUTO
#org.quartz.scheduler.threadsInheritContextClassLoaderOfInitializer = true

#============================================================================
# Configure ThreadPool
#============================================================================

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
org.quartz.threadPool.threadPriority = 5

#============================================================================
# Configure JobStore
#============================================================================

org.quartz.jobStore.misfireThreshold = 60000

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.MSSQLDelegate
org.quartz.jobStore.useProperties = false
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.tablePrefix = QRTZ_

org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000

#============================================================================
# Configure Datasources
#============================================================================

org.quartz.dataSource.myDS.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
org.quartz.dataSource.myDS.URL = jdbc:sqlserver://mydbserver:51803;databaseName=quartz
org.quartz.dataSource.myDS.user = quartz
org.quartz.dataSource.myDS.password = quartz
org.quartz.dataSource.myDS.maxConnections = 5
org.quartz.dataSource.myDS.validationQuery=select 1

#============================================================================
# Configure Shutdown Plugin
#============================================================================

org.quartz.threadPool.makeThreadsDaemons=true
org.quartz.scheduler.makeSchedulerThreadDaemon=true
org.quartz.scheduler.interruptJobsOnShutdown=true
org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
org.quartz.plugin.shutdownhook.cleanShutdown = true


ApplicationContextListener:



public class ApplicationContextListener implements ServletContextListener {

private StdSchedulerFactory factoryMyAppJob;

@Override
public void contextInitialized(ServletContextEvent event) {
configureQuartzJobs(event.getServletContext());
}

@Override
public void contextDestroyed(ServletContextEvent arg0) {
try {
factoryMyAppJob.getScheduler().shutdown(false);
} catch (SchedulerException e) {
AppLogger.log(e);
}
}

private void configureQuartzJobs(ServletContext servletContext) {

String currentTime = new SimpleDateFormat("dd_MM_yyyy_HH").format(new Date());
String myAppGroup = "myAppGroup";
String myAppJob = "myAppJob";


try {



JobDetail job = JobBuilder.newJob(myAppJob.class).withIdentity(myAppJob, myAppGroup).build();

Trigger triggerMyApp = TriggerBuilder.newTrigger().withIdentity(myAppJob, myAppGroup)
.withSchedule(simpleSchedule()
.withIntervalInMinutes(3).repeatForever())
.build();

Properties propsMyAppJob = new Properties();

boolean production = ConfigurationUtils.isProductionEnvironment();

if (production) {
propsMyAppJob.load(this.getClass().getClassLoader().getResourceAsStream("quartzConfig.properties"));
factoryMyAppJob = new StdSchedulerFactory(propsMyAppJob);
} else {
factoryMyAppJob = new StdSchedulerFactory();
}
Scheduler scheduler = factoryMyAppJob.getScheduler();

if (scheduler.checkExists(job.getKey())) {
scheduler.deleteJob(job.getKey());
}

scheduler.scheduleJob(job, triggerMyApp);

scheduler.start();


} catch (ObjectAlreadyExistsException oae) {

} catch (Exception e) {
AppLogger.log(e);
}
}

}


please advise how to fix this issue.









share


























    up vote
    0
    down vote

    favorite












    i am using quartz-2.2.3 on websphere 8.5.5 on a cluster environment where i have 2 nodes and on each node there are 3 JVMS



    i am configuring the job on application startup.



    ISSUE: the job is getting configured one time on each node, and what i expect is that it will be configured only one time on both nodes not one on each node.



    my configuration is as follows :



    quartzConfig.properties:



    #============================================================================
    # Configure Main Scheduler Properties
    #============================================================================

    org.quartz.scheduler.instanceName = MyJobScheduler
    org.quartz.scheduler.instanceId = AUTO
    #org.quartz.scheduler.threadsInheritContextClassLoaderOfInitializer = true

    #============================================================================
    # Configure ThreadPool
    #============================================================================

    org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
    org.quartz.threadPool.threadCount = 25
    org.quartz.threadPool.threadPriority = 5

    #============================================================================
    # Configure JobStore
    #============================================================================

    org.quartz.jobStore.misfireThreshold = 60000

    org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
    org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.MSSQLDelegate
    org.quartz.jobStore.useProperties = false
    org.quartz.jobStore.dataSource = myDS
    org.quartz.jobStore.tablePrefix = QRTZ_

    org.quartz.jobStore.isClustered = true
    org.quartz.jobStore.clusterCheckinInterval = 20000

    #============================================================================
    # Configure Datasources
    #============================================================================

    org.quartz.dataSource.myDS.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
    org.quartz.dataSource.myDS.URL = jdbc:sqlserver://mydbserver:51803;databaseName=quartz
    org.quartz.dataSource.myDS.user = quartz
    org.quartz.dataSource.myDS.password = quartz
    org.quartz.dataSource.myDS.maxConnections = 5
    org.quartz.dataSource.myDS.validationQuery=select 1

    #============================================================================
    # Configure Shutdown Plugin
    #============================================================================

    org.quartz.threadPool.makeThreadsDaemons=true
    org.quartz.scheduler.makeSchedulerThreadDaemon=true
    org.quartz.scheduler.interruptJobsOnShutdown=true
    org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
    org.quartz.plugin.shutdownhook.cleanShutdown = true


    ApplicationContextListener:



    public class ApplicationContextListener implements ServletContextListener {

    private StdSchedulerFactory factoryMyAppJob;

    @Override
    public void contextInitialized(ServletContextEvent event) {
    configureQuartzJobs(event.getServletContext());
    }

    @Override
    public void contextDestroyed(ServletContextEvent arg0) {
    try {
    factoryMyAppJob.getScheduler().shutdown(false);
    } catch (SchedulerException e) {
    AppLogger.log(e);
    }
    }

    private void configureQuartzJobs(ServletContext servletContext) {

    String currentTime = new SimpleDateFormat("dd_MM_yyyy_HH").format(new Date());
    String myAppGroup = "myAppGroup";
    String myAppJob = "myAppJob";


    try {



    JobDetail job = JobBuilder.newJob(myAppJob.class).withIdentity(myAppJob, myAppGroup).build();

    Trigger triggerMyApp = TriggerBuilder.newTrigger().withIdentity(myAppJob, myAppGroup)
    .withSchedule(simpleSchedule()
    .withIntervalInMinutes(3).repeatForever())
    .build();

    Properties propsMyAppJob = new Properties();

    boolean production = ConfigurationUtils.isProductionEnvironment();

    if (production) {
    propsMyAppJob.load(this.getClass().getClassLoader().getResourceAsStream("quartzConfig.properties"));
    factoryMyAppJob = new StdSchedulerFactory(propsMyAppJob);
    } else {
    factoryMyAppJob = new StdSchedulerFactory();
    }
    Scheduler scheduler = factoryMyAppJob.getScheduler();

    if (scheduler.checkExists(job.getKey())) {
    scheduler.deleteJob(job.getKey());
    }

    scheduler.scheduleJob(job, triggerMyApp);

    scheduler.start();


    } catch (ObjectAlreadyExistsException oae) {

    } catch (Exception e) {
    AppLogger.log(e);
    }
    }

    }


    please advise how to fix this issue.









    share
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      i am using quartz-2.2.3 on websphere 8.5.5 on a cluster environment where i have 2 nodes and on each node there are 3 JVMS



      i am configuring the job on application startup.



      ISSUE: the job is getting configured one time on each node, and what i expect is that it will be configured only one time on both nodes not one on each node.



      my configuration is as follows :



      quartzConfig.properties:



      #============================================================================
      # Configure Main Scheduler Properties
      #============================================================================

      org.quartz.scheduler.instanceName = MyJobScheduler
      org.quartz.scheduler.instanceId = AUTO
      #org.quartz.scheduler.threadsInheritContextClassLoaderOfInitializer = true

      #============================================================================
      # Configure ThreadPool
      #============================================================================

      org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
      org.quartz.threadPool.threadCount = 25
      org.quartz.threadPool.threadPriority = 5

      #============================================================================
      # Configure JobStore
      #============================================================================

      org.quartz.jobStore.misfireThreshold = 60000

      org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
      org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.MSSQLDelegate
      org.quartz.jobStore.useProperties = false
      org.quartz.jobStore.dataSource = myDS
      org.quartz.jobStore.tablePrefix = QRTZ_

      org.quartz.jobStore.isClustered = true
      org.quartz.jobStore.clusterCheckinInterval = 20000

      #============================================================================
      # Configure Datasources
      #============================================================================

      org.quartz.dataSource.myDS.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
      org.quartz.dataSource.myDS.URL = jdbc:sqlserver://mydbserver:51803;databaseName=quartz
      org.quartz.dataSource.myDS.user = quartz
      org.quartz.dataSource.myDS.password = quartz
      org.quartz.dataSource.myDS.maxConnections = 5
      org.quartz.dataSource.myDS.validationQuery=select 1

      #============================================================================
      # Configure Shutdown Plugin
      #============================================================================

      org.quartz.threadPool.makeThreadsDaemons=true
      org.quartz.scheduler.makeSchedulerThreadDaemon=true
      org.quartz.scheduler.interruptJobsOnShutdown=true
      org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
      org.quartz.plugin.shutdownhook.cleanShutdown = true


      ApplicationContextListener:



      public class ApplicationContextListener implements ServletContextListener {

      private StdSchedulerFactory factoryMyAppJob;

      @Override
      public void contextInitialized(ServletContextEvent event) {
      configureQuartzJobs(event.getServletContext());
      }

      @Override
      public void contextDestroyed(ServletContextEvent arg0) {
      try {
      factoryMyAppJob.getScheduler().shutdown(false);
      } catch (SchedulerException e) {
      AppLogger.log(e);
      }
      }

      private void configureQuartzJobs(ServletContext servletContext) {

      String currentTime = new SimpleDateFormat("dd_MM_yyyy_HH").format(new Date());
      String myAppGroup = "myAppGroup";
      String myAppJob = "myAppJob";


      try {



      JobDetail job = JobBuilder.newJob(myAppJob.class).withIdentity(myAppJob, myAppGroup).build();

      Trigger triggerMyApp = TriggerBuilder.newTrigger().withIdentity(myAppJob, myAppGroup)
      .withSchedule(simpleSchedule()
      .withIntervalInMinutes(3).repeatForever())
      .build();

      Properties propsMyAppJob = new Properties();

      boolean production = ConfigurationUtils.isProductionEnvironment();

      if (production) {
      propsMyAppJob.load(this.getClass().getClassLoader().getResourceAsStream("quartzConfig.properties"));
      factoryMyAppJob = new StdSchedulerFactory(propsMyAppJob);
      } else {
      factoryMyAppJob = new StdSchedulerFactory();
      }
      Scheduler scheduler = factoryMyAppJob.getScheduler();

      if (scheduler.checkExists(job.getKey())) {
      scheduler.deleteJob(job.getKey());
      }

      scheduler.scheduleJob(job, triggerMyApp);

      scheduler.start();


      } catch (ObjectAlreadyExistsException oae) {

      } catch (Exception e) {
      AppLogger.log(e);
      }
      }

      }


      please advise how to fix this issue.









      share













      i am using quartz-2.2.3 on websphere 8.5.5 on a cluster environment where i have 2 nodes and on each node there are 3 JVMS



      i am configuring the job on application startup.



      ISSUE: the job is getting configured one time on each node, and what i expect is that it will be configured only one time on both nodes not one on each node.



      my configuration is as follows :



      quartzConfig.properties:



      #============================================================================
      # Configure Main Scheduler Properties
      #============================================================================

      org.quartz.scheduler.instanceName = MyJobScheduler
      org.quartz.scheduler.instanceId = AUTO
      #org.quartz.scheduler.threadsInheritContextClassLoaderOfInitializer = true

      #============================================================================
      # Configure ThreadPool
      #============================================================================

      org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
      org.quartz.threadPool.threadCount = 25
      org.quartz.threadPool.threadPriority = 5

      #============================================================================
      # Configure JobStore
      #============================================================================

      org.quartz.jobStore.misfireThreshold = 60000

      org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
      org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.MSSQLDelegate
      org.quartz.jobStore.useProperties = false
      org.quartz.jobStore.dataSource = myDS
      org.quartz.jobStore.tablePrefix = QRTZ_

      org.quartz.jobStore.isClustered = true
      org.quartz.jobStore.clusterCheckinInterval = 20000

      #============================================================================
      # Configure Datasources
      #============================================================================

      org.quartz.dataSource.myDS.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
      org.quartz.dataSource.myDS.URL = jdbc:sqlserver://mydbserver:51803;databaseName=quartz
      org.quartz.dataSource.myDS.user = quartz
      org.quartz.dataSource.myDS.password = quartz
      org.quartz.dataSource.myDS.maxConnections = 5
      org.quartz.dataSource.myDS.validationQuery=select 1

      #============================================================================
      # Configure Shutdown Plugin
      #============================================================================

      org.quartz.threadPool.makeThreadsDaemons=true
      org.quartz.scheduler.makeSchedulerThreadDaemon=true
      org.quartz.scheduler.interruptJobsOnShutdown=true
      org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
      org.quartz.plugin.shutdownhook.cleanShutdown = true


      ApplicationContextListener:



      public class ApplicationContextListener implements ServletContextListener {

      private StdSchedulerFactory factoryMyAppJob;

      @Override
      public void contextInitialized(ServletContextEvent event) {
      configureQuartzJobs(event.getServletContext());
      }

      @Override
      public void contextDestroyed(ServletContextEvent arg0) {
      try {
      factoryMyAppJob.getScheduler().shutdown(false);
      } catch (SchedulerException e) {
      AppLogger.log(e);
      }
      }

      private void configureQuartzJobs(ServletContext servletContext) {

      String currentTime = new SimpleDateFormat("dd_MM_yyyy_HH").format(new Date());
      String myAppGroup = "myAppGroup";
      String myAppJob = "myAppJob";


      try {



      JobDetail job = JobBuilder.newJob(myAppJob.class).withIdentity(myAppJob, myAppGroup).build();

      Trigger triggerMyApp = TriggerBuilder.newTrigger().withIdentity(myAppJob, myAppGroup)
      .withSchedule(simpleSchedule()
      .withIntervalInMinutes(3).repeatForever())
      .build();

      Properties propsMyAppJob = new Properties();

      boolean production = ConfigurationUtils.isProductionEnvironment();

      if (production) {
      propsMyAppJob.load(this.getClass().getClassLoader().getResourceAsStream("quartzConfig.properties"));
      factoryMyAppJob = new StdSchedulerFactory(propsMyAppJob);
      } else {
      factoryMyAppJob = new StdSchedulerFactory();
      }
      Scheduler scheduler = factoryMyAppJob.getScheduler();

      if (scheduler.checkExists(job.getKey())) {
      scheduler.deleteJob(job.getKey());
      }

      scheduler.scheduleJob(job, triggerMyApp);

      scheduler.start();


      } catch (ObjectAlreadyExistsException oae) {

      } catch (Exception e) {
      AppLogger.log(e);
      }
      }

      }


      please advise how to fix this issue.







      java quartz-scheduler quartz





      share












      share










      share



      share










      asked 3 mins ago









      Mahmoud Saleh

      15.4k97286442




      15.4k97286442





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203389%2fquartz-doesnt-work-properly-in-cluster-environment%23new-answer', 'question_page');
          }
          );

          Post as a guest





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203389%2fquartz-doesnt-work-properly-in-cluster-environment%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Schultheiß

          Verwaltungsgliederung Dänemarks

          Liste der Kulturdenkmale in Wilsdruff