5 Replies Latest reply on Jul 19, 2018 8:03 AM by Cheng Fang

    Using different job repositories?

    Christoph Rettig Newbie

      Hello,

       

      I want to use different (JDBC) job repositories in one JBoss application server to separate jobs for different tenants.; my plan is that the jobs for every tenant are packaged into its own WAR package and deployed to the same JBoss.

       

      In JBoss using admin console I can configure multiple JOB repositories (memory or JDBC) but I am not sure how I can tell some Job (specified using the xml job language and contained in a WAR) to use a specific job respository?

       

      e.g.

       

      • Tenant-A.war -> connect to JDBC repository A
      • Tenant-B.war -> connect to JDBC repository B
      • Tenant-X.war -> connect to in-memory repository X (for demos)

       

      Many thanks for answering this simple question,

       

      regards, chris

        • 1. Re: Using different job repositories?
          Cheng Fang Master

          In admin console, you can create JDBC job repositories, and assign one of them as the default batch job repository (say, jdbc1) for the entire application server.  It means all deployed batch applications will by default use this job repository (jdbc1).

           

          You can also configure a custom job repository for each application via jboss-all.xml to override the default server-wide job repository.  Please see the batch subsystem schema in your application server for more details.

           

          Batch (JSR-352) Subsystem Configuration - Latest WildFly Documentation - Project Documentation Editor

          • 2. Re: Using different job repositories?
            Christoph Rettig Newbie

            Hello,

             

            Does this jboss-all.xml also apply to .WAR deployments or do I have to provide an .EAR for it to work?

             

            If I understand right then I would place this jboss-all.xml into every of my .WAR files under WEB-INF/jboss-all.xml and each pointing to a different data, e.g.

             

            Tenant-A.war

             

             

            <jboss umlns="urn:jboss:1.0">

             

                <batch xmlns="urn:jboss:batch-jberet:1.0">

                  <job-repository>

                    <named name="batch-ds-A"/>

                  </job-repository>

                  <thread-pool name="deployment-thread-pool"/>

                </batch>

            </jboss>

             

            Tenant-B.war

             

             

            <jboss umlns="urn:jboss:1.0">

             

                <batch xmlns="urn:jboss:batch-jberet:1.0">

                  <job-repository>

                    <named name="batch-ds-B"/>

                  </job-repository>

                  <thread-pool name="deployment-thread-pool"/>

                </batch>

            </jboss>

            ...

             

            (Provided that I have configured the dfifferent data sources before in the admin console).

             

            Right?

             

            chris

            • 3. Re: Using different job repositories?
              Cheng Fang Master

              yes, you can include jboss-all.xml in each WAR file to customize its configuration.

               

              You don't have to include <thread-pool> element, unless you want to customize thread-pool too.

               

              The job-repository named element refers to the name of the job repository that you've already defined in WildFly server configuration through either CLI or Management Console.

              • 4. Re: Using different job repositories?
                Christoph Rettig Newbie

                Hello,

                 

                I tried it out now and it works perfectly . many thanks for the help here

                 

                One last question on this: in the database table JOB_INSTANCE there is one column APPLICATIONNAME and here I see the name

                of my war file (which is uniqa-ecm-batch-processing-1.0.0-SNAPSHOT).

                 

                Is it possible to start a job and provide the applicationname myself so that not the name of the deployable (WAR file) is used here?

                 

                regards, chris

                • 5. Re: Using different job repositories?
                  Cheng Fang Master

                  No, currently applicationname is not configurable.