我一直试图通过Java运行水壶任务。该作业正在运行,但是参数也通过代码传递给该作业,但它不会与mongoDB通讯。
这里有代码,我正在尝试使用。
Properties prop = new Properties();
InputStream input = null;
input = getClass().getClassLoader().getResourceAsStream("config.properties");
prop.load(input);
String KettleJob = prop.getProperty("Kettle_Job_Param");//Job file path that needs to be executed
Repository repository = null; //Checking for repository
getProjectUnits.updateProjectStatus(User_ID, Project_ID, "4");
try {
KettleEnvironment.init();
}catch (Exception e) {
System.out.println("Kettle Error");
}
JobMeta jobmeta=new JobMeta(KettleJob,repository);
Job job=new Job(repository, jobmeta);
/* Doing the basic initialization for executing a job */
job.initializeVariablesFrom(null);
job.getJobMeta().setInternalKettleVariables(job);
job.copyParametersFrom(job.getJobMeta());
/* Setting the Parameters to the job object
* @Parameter Names: PARAM_ID and PARAM_NAME*/
job.setParameterValue("User_ID", User_ID);
job.setParameterValue("Project_ID", Project_ID);
//job.setLogLevel(LogLevel.MINIMAL);
//job.setLogLevel(LogLevel.ERROR);
//job.setLogLevel(LogLevel.DEBUG);
job.setLogLevel(LogLevel.ROWLEVEL);
/*Activating the Parameters and executing the Job */
job.activateParameters();
job.shareVariablesWith(jobmeta);
job.execute(0, null);
job.waitUntilFinished();
if(job.getErrors()>0){
getProjectUnits.updateProjectStatus(User_ID, Project_ID, "5");
return Response.status(Status.INTERNAL_SERVER_ERROR).entity("Error while initiating process.").build();
}
job.setFinished(true);
getProjectUnits.updateProjectStatus(User_ID, Project_ID, "6");
BasicDBObject status = new BasicDBObject();
status.put("Status", 1);
return Response.ok().entity(status.toString()).build();
与Maven的依赖关系如下:
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>${pentaho-kettle.version}</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-dbdialog</artifactId>
<version>${pentaho-kettle.version}</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<version>${pentaho-kettle.version}</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-ui-swt</artifactId>
<version>${pentaho-kettle.version}</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle5-log4j-plugin</artifactId>
<version>5.0.0.1</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libformula</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-big-data-plugin</artifactId>
<version>5.1.0.0-751</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-mongodb-plugin</artifactId>
<version>5.1.0.0-751</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-mongo-utils</artifactId>
<version>5.1.0.0-751</version>
</dependency>
它没有显示任何错误,但是由作业完成的更改未反映在mongoDB中。