0

I'm writing out some messages to oozie.action.output.properties file in java action called through oozie workflow. That message is retrieved in next workflow using ${wf:actionData('<action>')['<messageKey>']}. But, sometimes I need not write any message to properties file. In such case, oozie gives error message when retrieving the message as variable [<messageKey>] cannot be resolved. If it returns null or empty, I can continue with the workflow but if fails with the mentioned error. or How can I verify if that variable exists or no message exists for that messageKey. Example snippet:

<action name="fail-check">
      <sub-workflow>
         <app-path>${wf:appPath()}/../fail-check</app-path>
         <propagate-configuration />
         <configuration>
           <property>
             <name>dataPrepSetupMsg</name>
             <value>${wf:actionData('setup')['errMsg']}</value>

Inside JAVA action:

if(message != null){
    final String filePath = System.getProperty("oozie.action.output.properties");
    properties.put(errorMessage, message); 
    OutputStream outputStream = new FileOutputStream(filePath);
    properties.store(outputStream, null);
}
Mike
  • 725
  • 2
  • 11
  • 21
  • Did you check with the decision node action ? – K S Nidhin Feb 12 '16 at 17:17
  • Yes, I check with decision node action. After the java action is completed, I check with the decision node if there is any message with wf:actionData, then I use that message in following action. But, if there is no message, oozie errors out. – Mike Feb 12 '16 at 17:26
  • *"sometimes I need not write any message to properties file"* means that you don't even *create* an empty file at startup? – Samson Scharfrichter Feb 13 '16 at 12:47
  • What version of Oozie are you running, by the way? – Samson Scharfrichter Feb 13 '16 at 12:49
  • Can you provide snippet how are using the retrieved message. Probably you can write a dummy/default message instead of not writing anything at all. – YoungHobbit Feb 14 '16 at 16:00

0 Answers0