How to make the JavaExecute component to fail

Discussion on developing CloverETL engine, transformation components etc.

evijayan2
Posts: 3
Joined: Fri Mar 07, 2014 8:26 pm

How to make the JavaExecute component to fail

Postby evijayan2 » Fri Mar 07, 2014 8:34 pm

hi team,

i have a situation,

if the inputfile is empty, the graph have to fail.

i use the UniversaldataReader to read the file. I felt no option in datareader.

So i used the javaExecute component to validate the input file. the run() metghon returns void, so i cant mark as failed.( i have to give system.exit(-1)).

other wise init() method to return false, then clover server throws componentinitialization failed exception.

Please help me to resolve this situation.

novakj
Posts: 54
Joined: Wed Sep 04, 2013 11:55 am

Re: How to make the JavaExecute component to fail

Postby novakj » Mon Mar 10, 2014 12:53 pm

Hi,

If your validation of input file fails, you can throw runtime exception. This exception will interrupt graph processing.

Example of a class with runtime exception:

Code: Select all

import org.jetel.component.BasicJavaRunnable;
import org.jetel.exception.JetelRuntimeException;

public class MyClass extends BasicJavaRunnable {

   @Override
   public void run() {
      
      // write into information log
      getNode().getLog().info("Custom info message");
      
      // Component JavaExecute will finish with status error with following message
      throw new JetelRuntimeException("Input file is empty");
   }

}


In console you can see:

Code: Select all

ERROR [main] -
--------------------------------- Error details ----------------------------------
  Component [JavaExecute:JAVA_EXECUTE] finished with status ERROR.
   Input file is empty
----------------------------------------------------------------------------------
ERROR [main] - Execution of graph failed !
Jiri Novak
CloverCARE Support
CloverETL | Rapid Data Integration

Visit us online at http://www.cloveretl.com

evijayan2
Posts: 3
Joined: Fri Mar 07, 2014 8:26 pm

Re: How to make the JavaExecute component to fail

Postby evijayan2 » Wed May 07, 2014 9:42 pm

Thanks


cron