0

I have a batch job which runs perfectly well in standalone mode. I converted the same to a spring xd batch job. I am using spring xd version 1.0.0.M5. Some issues I face:

(i) I do not want to use hsqldb as my spring.datasource. I wanted to switch to mysql. In order to do so I updated the xd-config.yml file to reflect the same. It did not work. I added a snippet (application.yml) to my job config folder with the relevant datasource information did not work. I set the spring.datasource related environment variables on the command line. It works. Q: Is there a way to have mysql be picked as the profile such that the relevant metadata is picked either from the application.yml snippet or the xd-config.yml snippet without me having to set the environment variable manually?

user3304825
  • 107
  • 2
  • 12

1 Answers1

1

The database configuration is still a work-in-progress. The goal for M6 is to have what you specify in xd-config.yml to control both the Spring Batch repository tables and the default for your batch jobs using JDBC.

In M5 there are separate settings to control this. The Spring Batch repository uses what is in config/xd-config.yml while the batch jobs you launch depend on config/batch-jdbc.properties. To use MySQL for both I changed:

config/xd-config.yml

#Config for use with MySQL - uncomment and edit with relevant values for your environment
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/xd
    username: spring
    password: password
    driverClassName: com.mysql.jdbc.Driver
  profiles:
    active: default,mysql

config/batch-jdbc.properties

# Setting for the JDBC batch import job module

url=jdbc:mysql://localhost:3306/xd
username=spring
password=password
driverClass=com.mysql.jdbc.Driver

# Whether to initialize the database on job creation, and the script to
# run to do so if initializeDatabase is true.
initializeDatabase=false
initializerScript=init_batch_import.sql
Thomas Risberg
  • 936
  • 5
  • 7
  • Hi Thomas - I tried with the config above (is it jdbc-batch or batch jdbc? :-) I tried modifying xd-config and also tried adding a "config\xd-config" snippet unde myjob\config. Neither works in M5 Release. The registry-schema-hsqldb.sql gets picked. The only way I can get the correct mysql variables to be picked is by setting them as environment variables on the command line. Another thing is all the dependency jars if I put them in the job\myjob\lib folder, they do not seem to be on the classpath, but If I put the same in %XD_HOME%\lib they get picked as expected. – user3304825 Mar 10 '14 at 16:20
  • Hi Thomas - The configs you mention above do not get detected from the classpath. I tried with the config above I tried modifying xd-config and tried adding a "config\xd-config" snippet unde myjob\config. None work in M5 Release. The registry-schema-hsqldb.sql gets picked. On a related note the dependency jars if I put them in the job\myjob\lib folder, they do not seem to be on the classpath, but If I put the same in %XD_HOME%\lib they get picked as expected. – user3304825 Mar 10 '14 at 16:30
  • Looking at the debug output it seems the only places it looks for the environment variables are systemProperties, systemEnvironment, random(?) and application.yml. Nothing seems to indicate it looking in xd-config.yml. – user3304825 Mar 10 '14 at 16:37
  • Mysql profile does not get added to the profiles although the relevant values are uncommented in the xd-config. Which makes me believe it never gets picked on the classpath. – user3304825 Mar 10 '14 at 17:08
  • Yes, it's batch-jdbc.properties. What OS are you running on - I just tested this with M5 on Ubuntu today and it works, HSQL db still gets started but the one used for the batch repo is MySQL. – Thomas Risberg Mar 11 '14 at 00:03
  • I am using windows 7 Enterprise. I checked the profiles. mysql does not get activated. Only "adminServer","single","default","hsqldb" do. I am running xd-singlenode – user3304825 Mar 11 '14 at 17:46