7 Replies Latest reply on Mar 11, 2017 2:20 AM by Sławomir Wojciechowski

    Job run suynchronously

    Sławomir Wojciechowski Newbie

      Hello,

       

      According to jsr specification jbatch jobs should run asynchronously. But some implementation, like batchee allow run job synchronously. From my point of view it's intresting feature. So is it possible to run jberet jobs asynchronously?

       

      Best Regards

      sw

        • 1. Re: Job run suynchronously
          Cheng Fang Master

          In JBeret, batch jobs are always run asynchornously.

           

          If you need to accurately time the job completion, you can use org.jberet.runtime.JobExecutionImpl#awaitTermination in co-located batch client.

           

          For both co-located and remote batch job client, the standard way is to periodically poll the batch job status.

           

          Can you elaborate why you need synchronous job run?

          • 2. Re: Job run suynchronously
            Sławomir Wojciechowski Newbie

            Hello,

             

            I'm sory for delay in response.

            My jobs as often heavy weight. Usually they download data from few databases (oracle and ms) and files. Then load data to other databases.

            So it's good idea to only one batch process should be running. I don't want to start pararell few long running sql quieries on databases because  it could create  performance problems on it. Database is using by other processes too.

             

            Regrads

            sw

            • 3. Re: Job run suynchronously
              Cheng Fang Master

              Do you need this feature in JBeret SE (standalone), or JBeret in Java EE (JBeret in WildFly / JBoss EAP)?

               

              You may be able to achieve the same effect by configuring the max pool size to 3, to block additional jobs being executed.

               

              In JBeret SE, see bin/jberet.properties

              thread-pool-max-size = 3

               

              In WildFly / JBoss EAP, you can modify this setting in admin console, or thru CLI

               

              bin > ./jboss-cli.sh

              [disconnected /] connect

              [standalone@localhost:9990 /] /subsystem=batch-jberet/thread-pool=batch:read-attribute(name=max-threads, include-defaults=true)

              {

                  "outcome" => "success",

                  "result" => 10

              }

               

              [standalone@localhost:9990 /] /subsystem=batch-jberet/thread-pool=batch:write-attribute(name=max-threads, value=3)

              {"outcome" => "success"}

               

              With the above setting, you can try submit a second job execution, and see if it is rejected or not.  I haven't tried it and would love to see how it turns out.

              • 4. Re: Job run suynchronously
                Sławomir Wojciechowski Newbie

                I use it on wildfly. I cant set minimal pool size becouse it blocks start other batchs from other applications.

                 

                Regars

                sw

                • 5. Re: Job run suynchronously
                  Cheng Fang Master

                  I just created the following JBeret JIRA issue for this topic:

                   

                  1. JBERET-318

                  Synchronous start of batch job execution

                  • 6. Re: Job run suynchronously
                    Cheng Fang Master

                    Even if JBeret supports synchronous job execution, there is nothing stopping your application from starting the same job a second time (as a distinct job instance), while the first job execution is still blocking.  Think of clicking the same link in a new browser tab.  This is not much different from starting a different job in a different deployment.  Though it will be easier to avoid that kind of duplicate starting with synchronous start.

                    • 7. Re: Job run suynchronously
                      Sławomir Wojciechowski Newbie

                      In my application is the only one singleton than can fire specific batch process. If batch process could be synchronously it guarantee that only one specific job is running.

                       

                      Best Regards

                      sw