How to stop a job sequence without aborting

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
shankar_ramanath
Premium Member
Premium Member
Posts: 67
Joined: Thu Aug 09, 2007 7:51 pm

How to stop a job sequence without aborting

Post by shankar_ramanath »

Hi,

I have a job sequence which executes a command that fetches a lot of files to the server, and then processes them. This sequence is scheduled to run daily.

However, it's fairly common that, for a given day, those files aren't present at the source. This should not be treated as an error, but I also need to stop all the further processing after that invocation since, without the files, the next job activities will fail.

To accomplish this, I have the ExecuteCommand activity, and three outbound links. One for return code 0 (success, proceed normally), one for return code 1 (FileNotFound) and one for Otherwise (error while trying to get the files).

Link success goes to the rest of the processing activities.
Link Error goes to a routineActivity that invokes a custom routine I coded that sends a custom email depending on the return code received.
Link FileNotFound goes to a termination activity, since I found no input files at the source and want to stop processing without sending the email.

This works, but also leaves my job in "Aborted" state, which the end user doesn't want.

Is there a way to stop the job execution without leaving the job in "aborted" state? Currently I found a workaround: In the custom email routine, I don't send the email if the return code is the one for FileNotFound. I suppose I could create a custom routine that does nothing but log a message and use a call to that using a RoutineActivity instead of a terminator, but I was wondering if there was a better, non-dirty way of doing this :)

thanks in advance.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Remove the Terminator (which aborts the job) and replace it with a Sequencer. Job just stops. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
paddu
Premium Member
Premium Member
Posts: 232
Joined: Tue Feb 22, 2005 11:14 am
Location: California

Post by paddu »

If you want to run the process only when retrurn code=0 then

Have two links from the command activity stage .

one for return code=0 , which executes rest of the processes .
one for otherwise , Which just exits the process and send an email with message ( could return code=1 or other error message).

This way you avoid the job getting aborted .

remove termination activity stage.
There is nothing good or bad, but thinking makes it so. --William Shakespeare
shankar_ramanath
Premium Member
Premium Member
Posts: 67
Joined: Thu Aug 09, 2007 7:51 pm

Post by shankar_ramanath »

chulett wrote:Remove the Terminator (which aborts the job) and replace it with a Sequencer. Job just stops. :wink:
Thanks Craig, I tried it and it works as expected.
Last edited by shankar_ramanath on Wed Feb 20, 2008 2:49 pm, edited 1 time in total.
shankar_ramanath
Premium Member
Premium Member
Posts: 67
Joined: Thu Aug 09, 2007 7:51 pm

Post by shankar_ramanath »

paddu wrote:If you want to run the process only when retrurn code=0 then

Have two links from the command activity stage .

one for return code=0 , which executes rest of the processes .
one for otherwise , Which just exits the process and send an email with message ( could return code=1 or other error message).

This way you avoid the job getting aborted .

remove termination activity stage.
Hi Paddu,

Thanks for your response.

Actually, what you describe is how it happens now. However, the email notifications are intended to happen only in case of an error, and I need this particular case to stop the job without the email (support mailing list members will thank me if I manage to do that ;) )

I just tried Craig's suggestion (replace Terminator with Sequencer) and it works ok. The return code for FileNotFound now links to a sequencer that's named "stopProcessing" and has a logging message of "No files found in server, stopping normally". Job ends, logs say why, and the status isn't aborted. Perfect!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Excellent. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply