Announcement Announcement Module
Collapse
No announcement yet.
scheduling a batch job Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    The QuartzBatchJob class is basicly a copy-paste of BatchCommandLineLauncher#start method - maybe it is worth to extract this logic from the "command line" class?[/QUOTE]



    could you please post the an example of QuartzBatchJob file. It doesn't come with spring batch examples and what you say about BatchCommandLineLauncher does not apply because it seems that that class was replaced by CommandLineJobRunner. Thanks.

    Comment


    • #17
      if it is useful for someone, my QuartzBatchJob (on m5) for the example given above is this one and it works fine:

      public class QuartzBatchJob extends QuartzJobBean implements StatefulJob {
      private JobLauncher launcher;
      protected static final Log logger = LogFactory.getLog(QuartzBatchJob.class);
      private JobParametersFactory jobParametersFactory = new DefaultJobParametersFactory();

      protected void executeInternal(JobExecutionContext ctx)
      throws JobExecutionException {

      try {
      ApplicationContext context = new ClassPathXmlApplicationContext(
      "org/springframework/batch/sample/PersonaJobFunctionalTests-context.xml");
      context.getAutowireCapableBeanFactory().autowireBe anProperties(
      this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
      String[] parametros={"par1=1","par2=2"};

      Job job = (Job) context.getBean("personaImportJob");
      JobParameters jobParameters = jobParametersFactory
      .getJobParameters(StringUtils
      .splitArrayElementsIntoProperties(parametros, "="));

      launcher.run(job, jobParameters);
      } catch (Throwable e) {
      logger.error("Job Terminated in error:", e);
      }

      // place your Job code here
      /** ********************** */
      System.out.println("EJECUTANDO QUARTZ JOB");
      }

      public void setLauncher(JobLauncher launcher) {
      this.launcher = launcher;
      }

      }

      Comment


      • #18
        The quartz sample has been ressurected after M5 and there is now QuartzBatchLauncher and eclipse launch configuration provided in the samples.

        Comment


        • #19
          Where is on m5 samples the eclipse launch configuration you say? I only see the same QuartzBatchLauncher that existed on m4 and nothing else.

          Comment


          • #20
            It has been added since M5, so it's in the latest trunk but not M5 itself. It should be included in RC1.

            Comment


            • #21
              BatchCommandLineLauncher in m5

              Originally posted by robert.kasanicky View Post
              One way is to use maven to launch the job - just add the snippet below to your pom.xml and use "mvn exec:exec -Djob.name=myJob -Djob.configuration.path=path/to/myJob.xml" as command (or you can hardcode the parameters).

              Code:
              <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>exec-maven-plugin</artifactId>
                                <executions>
                                    <execution>
                                        <goals>
                                            <goal>exec</goal>
                                        </goals>
                                    </execution>
                                </executions>
                                <configuration>
                                    <executable>java</executable>
                                    <arguments>
                                        <argument>-classpath</argument>
                                        <!-- automatically creates the classpath using all project dependencies, 
                                            also adding the project build directory -->
                                        <classpath />
                                        <!-- job configuration file -->
                                        <argument>-Djob.configuration.path=${job.configuration.path}</argument>
                                        <!-- job name -->
                                        <argument>-Djob.name=${job.name}</argument>
                                        <argument>
                                            org.springframework.batch.execution.bootstrap.support.BatchCommandLineLauncher
                                        </argument>
                                    </arguments>
                                </configuration>
                            </plugin>
              BatchCommandLineLauncher is not available in m5 that I can see. How is this done in m5 or am I missing something? Thanks!

              Comment


              • #22
                I think it's called CommandLineJobRunner.

                Comment


                • #23
                  CommandLineJobRunner also uses command line arguments instead of VM arguments.

                  Comment

                  Working...
                  X