Search code examples
while-loopnullamazon-redshifttalend

Talend tLoop problem with conditions and nulls


I have a job which needs to insert a row (into Redshift) and then wait for another process to update a value in one of the fields. The field is null to start, and as long as it stays null, the job waits and polls each minute. When the field is updated: if it's 0, end - reporting success; if it's not 0, end - reporting failure.

I have the insert, the waiting (using a tLoop and Thread.sleep), and the querying the new row.

But I don't know how to structure my last step. I have a tJavaRow where I check if the return_code is not null and set my looping condition to end the loop. Then the else clause performs the sleep and then a continue statement.

From the tJavaRow I have three outputs: One is to a tJava (empty, because I have to have an output), then two if conditions (flows) that just Close the RS connection (if rc = 0), or tDie (if rc != 0).

I am getting a NullPointerException (of course), but I suspect my approach is somehow off.

My question: How do I fix the NullPointerExecption (if that's the real problem--probably not) or how do I change my job to accomplish what I want. I mean "...want?"

image of the job: job current structure


Solution

  • Close - if : (rc != null && rc == 0) tDie - if : (rc != null && rc != 0)

    As far as I understand this issue, I hope this will work..