Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
When I encounter a java error, my jobs are stopped. I would like to log errors and continue. I'm working with Talend Open Studio V8, I saw there are ctry components but it doesn't seem to exist for TOS. Is there a solution?
Thank you for advance.
The cTry component is for the ESB product. I presume that you are using the Date Integration product. If that is the case your job is not going to be suitable to start running in Prod until you actively prevent Java errors with your data. I presume that many of them will be NullPointException errors. If so, this will mean that your job is not built to handle data that is null....or where there is no data in a column. This should not error and continue because then you will have lost that data. You need to build a path in the job to check for this, then handle it without causing a Java error.
I use Talend Open Studio. Of course, I would like to know that the data was not imported with the onsubjoberror. If the subjob is in error, I log the error with the name of file not imported, if the subjob is ok I log the file as imported. In this specific case, I am reading a file produced by a machine. I check its presence, then I come to read it, this file contains many lines, the errors can be multiple, I could try to anticipate all the possible errors, but the simplest would be to say, if there is an error in this subjob, I log and I move on to reading and importing the next file.
Ah OK. I just wanted to make sure that you were not trying to brute force the job to complete as that is seldom what is required. If you are wanting to validate your file's schema and report on each error, you can use the tSchemaComplianceCheck component (https://help.talend.com/r/en-US/8.0/validation/tschemacompliancecheck-standard-properties).
The best way to do this is to read every column from your file as a String. Flat file data can always be read initially as a String. Then connect the tSchemaComplianceCheck component and add the schema you are looking for. So, for example, if columns 1,4 and 6 are Integers, set those as Integer. If columns 2, 3 and 5 are Strings, set those as Strings. If column 7 is a Date, set that as Date (check the expected format. Then, when you run the job, the component will assess the columns of each row. If any are in the wrong format or missing data, etc, the component will output the row to the "Rejects" output, if the row is OK it will output to the "Main" output.
If you collect your results from each path in something like a tHashInput or a tHSQLDbInput, you can assess whether you have any issues by using the components' globalMap "Number of line" values. You can use these numbers with RunIf links to send the job to the next SubJob to complete the processing if it is good OR to an error SubJob to log your errors if it is bad.