Four Stars EM
Four Stars

run if problem , seems not working

my problem is that "run if trigger " seems not working:

In my project, i connect  to different Databse, based on a Json input, than, i need to create different CSV file, based on what data is contained on JSON file, for example, if  that json value are 1, it will produce the respective CSV file.

to achieve this, i use "run if", but they don't work,  always produce all CSV1.png2.png3.png

 

of course, i use context  filled with value read from json to trigger run if, only last, using MYSQL work, the first not.

I THINK THE PROBLEM ARE THE  "RUN IF", AS YOU CAN SEE, THEY ARE DIFFERENT IN THE MYSQL (  if (order:1) why in the first screen is if , and this could be the problem , but i'm not able to recreate run if as in the last )

right mouse click, run if and then link to step, and then set if condition, what i'm wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Fifteen Stars

Re: run if problem , seems not working

Look at the components with the green backgrounds....that indicates the component is the first of a subjob. Now look at the arrows on the RunIfs connecting those components. The RunIfs links are going in the wrong direction on the jobs which are not working. You click on the component you want to start from, select the RunIf and then drag it to the component you want to go to. This is what is wrong.

 

Regarding the parent job, it looks OK. But I suspect you are using some "rows" where maybe OnComponentOK or OnSubjobOK links would be better placed. However, I'd need to look at the job in more detail to see whether that is strictly the case.

 

I re-read my previous post and it might have come across as a bit patronising. That was not the intention. I just believe it is very important to be given the time to get a good grounding in Talend before your company get you to start building in it. Mistakes made early on can be really difficult to refactor in the future and problems like this can take up a lot of your time.

Rilhia Solutions
9 REPLIES
Fifteen Stars

Re: run if problem , seems not working

The RunIfs are fine, your context variable does not hold a value that you expect at the time the RunIfs are triggered. How are you setting this context variable?

Rilhia Solutions
Four Stars EM
Four Stars

Re: run if problem , seems not working

with context.name of context = variable i read from Json input

Four Stars EM
Four Stars

Re: run if problem , seems not working

but, the run if with myswl connection work, with MSQL not, same use of context

Also, these are subjob, that i call from Mainjob, and pass them all context

Also, i'm sure my context is correct , because, i print some log in console, one value is 1, one is 0, so, it must produce only one CSV, but instead, it produce both. And this is not happening in MySQL run if

Fifteen Stars

Re: run if problem , seems not working

There are several things I need to know.....

 

1) Where is the JSON input? I don't see it. It looks like what is in the images is the entire job. If that is the case, how are the context variables being assigned? 

2) If the JSON load is in the job, but not shown, then the job is badly written. You MUST connect ALL subjobs (that are not connected to a tPostJob, tPreJob or logging components) or the order will be random. This *could* be a reason.

3) Are there any error messages?

4) Can you show me all of the RunIf conditions?

 

I know the RunIf links are not broken. This is not a possibility I'm afraid. The problem is caused by something in your configuration, but you will need to give a lot more info to identify it.

Rilhia Solutions
Four Stars EM
Four Stars

Re: run if problem , seems not working

this work3.png

and this not1.png

i use tjava to print log System.out.println...... and it sais 1  and 0 ,so, according to my if condition :

context.FREQUENTI_01 == 1  and 

context.ANAGRAFICHE_AGENTI == 1

it should create only one file , but it create both.

WHILE, the FIRSTscreen works and create file depending from value , if in my json i put 0  and 0 it don't create anything, if 1 ad 0 it create one, if 1 and 1 it create both

Fifteen Stars

Re: run if problem , seems not working

OK some friendly advice, you need to go through some tutorials before working with Talend.

 

These are your issues....

 

1) Your RunIfs are the wrong way around in the scenario where it doesn't work. The best way to write jobs is to start with components on the left at the top and then work to the right and down. You started with the two tMySQLInput components and linked your RunIfs to the tJava on the left and then to the tConnection. Essentially creating your connection after the firing the query.

 

2) As you fired your query before creating your connection, your tMySQLInput components I am guessing create their own connections. This is fine, but renders the connection useless.

 

3) If you are passing JSON data into your job to assign context variable values, it looks like it is not connected to the flow of subjobs. As I said before, this means that it is not necessarily firing before you are trying to use the context variables. This is bad.

 

The reason the first job works is down to luck. You started with the tMySQLConnection component and worked from there BUT if you have any other unconnected subjobs in that job, you are never going to be sure which will fire first. 

 

There are lots of Talend tutorials around. I have a few on my website, but I would recommend Googling "Talend Tutorials" to get to grips with the fundamentals. 

Rilhia Solutions
Four Stars EM
Four Stars

Re: run if problem , seems not working

this is my project main.png

from data it read from JSON, it will run appropirate subjob at trunjob

 

here are the subjob

subjob1.png

 

 

 

 

subjob3.pngsubjob4.png

Fifteen Stars

Re: run if problem , seems not working

Look at the components with the green backgrounds....that indicates the component is the first of a subjob. Now look at the arrows on the RunIfs connecting those components. The RunIfs links are going in the wrong direction on the jobs which are not working. You click on the component you want to start from, select the RunIf and then drag it to the component you want to go to. This is what is wrong.

 

Regarding the parent job, it looks OK. But I suspect you are using some "rows" where maybe OnComponentOK or OnSubjobOK links would be better placed. However, I'd need to look at the job in more detail to see whether that is strictly the case.

 

I re-read my previous post and it might have come across as a bit patronising. That was not the intention. I just believe it is very important to be given the time to get a good grounding in Talend before your company get you to start building in it. Mistakes made early on can be really difficult to refactor in the future and problems like this can take up a lot of your time.

Rilhia Solutions
Four Stars EM
Four Stars

Re: run if problem , seems not working

very thanks, it was the problem

i spent a lot of days trieing to solve 

very very thanks

good work