How to stop further processing when error occurs

I have a runbook that reads the *.xml files (oldest to newest) from a share. It then bulk inserts each XML file into an SQL DB.

This works fine. What I would like to have is that the processing stops completely when, for whatever reason, the bulk import fails. What happens now is that when there are 5 files in the share, and the 3th import fails, that files 4 and 5 are imported. Since there is a specific order in which the files need to be imported, the runbook needs to stop from processing any other files when one fails.

How can this be done?

June 29th, 2015 9:35am

Hi,

with the "Query Database" Activity you get the Results and not the Messages fom SQL statements.

If the statement has worked you can put "Select 0" if not "Select 1" to the end. In the link after the "Query Database" Activity you can filter to trigger only if "Full line as a string sepraeted by ';' equals 0".

Regards,

Stefan

Free Windows Admin Tool Kit Click here and download it now
June 29th, 2015 12:04pm

Hi Stefan,

Thanks for the answer. That works for the one file that fails to load, but then the runbook continues with the next file, like this:

  • Read User XML file finds 4 xml files in the share
  • Processing file 1
    • Logging file 1 information
    • Loading file one in DB succeeds
    • File is moved to processed folder
    • Logging file 1 move result
  • Processing file 2
    • Logging file 2 information
    • Loading file one in DB succeeds
    • File is moved to processed folder
    • Logging file 2 move result
  • Processing file 3
    • Logging file 3 information
    • Loading file one in DB fails! And processing stops for file 3
  • Processing file 4
    • Logging file 4 information
    • Loading file one in DB succeeds
    • File is moved to processed folder
    • Logging file 4 move result

So, while processing file 3, it will not move the file because the SQL query failed and that is perfect. But then it continues with file 4 and I dont want file 4 to be processed since file 3 failed.

June 29th, 2015 1:39pm

Hi,

perhaps this post from me helps: http://www.sc-orchestrator.eu/index.php/scoblog/49-cycles-in-pipleline-mode

Regards,

Stefan

Free Windows Admin Tool Kit Click here and download it now
June 29th, 2015 1:55pm

Hi Peter, 

If I understand correctly you're describing the fact that Orchestrator splits the runbook execution into parallel threads when multiple results are returned from an activity like your "Read User XML File". There's really no way to enforce dependencies between parallel executions, so what you'd want to implement is a serial looping instead of a parallel split.

You could do this by creating a runbook that performs the processing and maintains a index using a counter in Orchestrator, which keeps track of which item is being processed. Then, return a success/failure status for each execution, and configure a parent runbook to invoke the processing runbook in a loop, where the loop exits if the result indicates failure in any iteration.

Does that help?

June 30th, 2015 9:52pm

Hi Stefan and Noah,

Thanks for your answers. You both describe a similar solution and that was exactly what I was looking for.

It works perfectly!

Kind regards,

Peter.

Free Windows Admin Tool Kit Click here and download it now
July 1st, 2015 3:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics