I'm using Cloud Dataflow API with Java Client Library to launch a Dataflow template. I want to know when the job that was launched has a status of JOB_STATE_DONE. Even though this is easy to do in node.js with callbacks, I really need to do it in Java, but it's being real hard to find examples of how to do it. I also not good at event-driven programming.
Node.js code:
var {google} = require('googleapis');
exports.runJob= (req, res) => {
google.auth.getApplicationDefault(function (err, authClient, projectId) {
if (err) {
throw err;
}
const dataflow = google.dataflow({ version: 'v1b3', auth: authClient });
dataflow.projects.templates.launch({
projectId: 'xxxxx',
gcsPath: 'gs://xxxx',
resource: {
parameters: {
},
environment: {
tempLocation: 'gs://xxx'
},
}
}, function(err, response) {
if (err) {
console.error("Errorw: ", err);
}
console.log("Job executed: ", response);
res.send('200');
})
});
};
Dependency:
compile group: 'com.google.apis', name: 'google-api-services-dataflow', version: 'v1b3-rev266-1.25.0'
Edit: I've noticed there is a setCallback(String) method in the documentation (link below), but I still don't know how to use it.