Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
My use case is quite simple, I use a tFileInputXML ------> tMap -------->tFileOutputXML
In the tMap, I want to use a routine do multiple specific checks on multiple dates columns from the input but :
- if the check fails, I would like to :
1) throw an exception to be caught and logged in a log file (I use a tAssert----->tFlowToIterate ---->tRunJob ) to write specific logging format to do this
2) return an empty date to be written in the XML output
- if the check is a success, I transform the date format to another pattern and send it to the output
My problem is that the throwing of an Exception (in my routine) seems to "kill" the whole row and does not allow me to return "" at the end... I do not succeed to throw an exception without rejecting the whole row.
Could you please help me with this ?
I have tried below example code in a routine.
package routines;
import routines.system.LogCatcherUtils;
import routines.system.ResumeUtil;
public class field_too_long {
/**
* helloExample: not return value, only print "hello" + message.
*
*
* {talendTypes} String
*
* {Category} User Defined
*
* {param} string("world") input: The string need to be printed.
* {param} LogCatcherUtils(tLogCatcher_1) input
* {param} Map(globalMap) input
* {param} ResumeUtil(resumeUtil) input
*
* {example} helloExemple("world") # hello world !.
*/
public static String String_too_long(String field, LogCatcherUtils tLogCatcher_1,final java.util.Map<String, Object> globalMap,ResumeUtil resumeUtil) {
String new_field = field;
String tmp = "";
tmp = field.replaceAll(" +", " ");
new_field = tmp.replaceAll("\t+", "\t");
if(new_field.length()>3){ //You can change it to 4000.
resumeUtil.addLog("USER_DEF_LOG", "NODE:tWarn_1", "", Thread
.currentThread().getId()
+ "", "WARN", "", "this is a warning", "", "");
tLogCatcher_1.addMessage("tWarn", "tWarn_1", 4,
"this is a warning", 42);
}
return new_field;
}
}
but I did not succeed to have those example work...
When not using tLogCatcher_1Process(globalMap) in the routine, it seems the log is not pushed to the tLogCatcher. But when I try to add it to the routine, I get a compilation error :
The method tLogCatcher_1Process(Map<String,Object>) is undefined for the type MyClass
Best regards.
xdshi wrote:
Hi hanoijolly,
Could you please post your current job setting screenshots into forum? Which will be helpful for us to address your issue.
Best regards
Sabrina