AppWorx, Dollar Universe and Sysload Community

 View Only
  • 1.  Error Handling in jobs

    Posted Aug 01, 2019 10:38 AM

    Hi All,

    we are running few .NET jobs through Automic. These .NET jobs do not return any exit code and that's why we are using error handling as provided in Automic with below statements.

    @IF EXIST "JobSuccessful.flag" (
    @del "JobSuccessful.flag"
    )

    D:\Jobs\TrueValue\bin\DebugJobHost.exe TvVertexJob.config
    @set retcode=%errorlevel%
    @ECHO Job retcode=%retcode%

    @IF EXIST "JobSuccessful.flag" (
    @ECHO Success Flag found, setting retcode=0
    @set retcode=0
    ) ELSE (
    @ECHO Success Flag NOT found, setting retcode=1
    @set retcode=1
    )
    @if NOT retcode == 0 goto :retcode

    now even if the job fails from .NET end, it is ENDED_OK on Automic. when we check the logs , We can see the error in the output

    Output Job A:.
    [375] [1] INFO TrueValue.Jobs.TrueValue.TvVertexJob.TaxTableTransaction - Getting the DB2 Tax Table Transactions in Host Location: PROD_DB2Region
    [375] [1] DEBUG TrueValue.Jobs.TrueValue.TvVertexJob.GetEmbeddedResources - reading embedded resource: getTaxTableRecords.sql
    [41937] [1] FATAL TrueValue.Jobs.TrueValue.TvVertexJob.TaxTableTransaction - getTaxTableTransactions:Error=ERROR [57014] [IBM][DB2] SQL0952N Processing was cancelled due to an interrupt.
    [41984] [1] INFO TrueValue.Jobs.TrueValue.TvVertexJob.TvVertexJob - Job ending. Total Time:JobStarted - 00:00:41.6093750
    JobStarted - 00:00:41.6093750
    [41984] [1] DEBUG TrueValue.Fry.Jobs.Host.Program - Finished Job TvVertexJob
    Process terminating normally, creating success flag file.
    Process Terminating: 0
    Job retcode=0
    Success Flag found, setting retcode=0

    Output Job B:

    [13140] [1] ERROR TrueValue.Jobs.TrueValue.OnlineRetailerOrderSubmitJob.OnlineRetailerOrderSubmitJob - an error occurred in UpdateOrderStatuses
    System.FormatException: Input string was not in a correct format.
    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
    at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
    at System.Convert.ToInt64(String value)
    at TrueValue.Jobs.TrueValue.OnlineRetailerOrderSubmitJob.OnlineRetailerOrderSubmitJob.<>c.<UpdateOrderStatuses>b__20_0(OrderStatus o)
    at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    at TrueValue.Jobs.TrueValue.OnlineRetailerOrderSubmitJob.OnlineRetailerOrderSubmitJob.UpdateOrderStatuses(String lastRunTime)
    [13468] [1] ERROR TrueValue.Jobs.TrueValue.OnlineRetailerOrderSubmitJob.OnlineRetailerOrderSubmitJob - an error occurred in OnlineRetailerOrderSubmitJob JobMain Method
    System.FormatException: Input string was not in a correct format.
    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
    at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
    at System.Convert.ToInt64(String value)
    at TrueValue.Jobs.TrueValue.OnlineRetailerOrderSubmitJob.OnlineRetailerOrderSubmitJob.<>c.<UpdateOrderStatuses>b__20_0(OrderStatus o)
    at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    at TrueValue.Jobs.TrueValue.OnlineRetailerOrderSubmitJob.OnlineRetailerOrderSubmitJob.UpdateOrderStatuses(String lastRunTime)
    at TrueValue.Jobs.TrueValue.OnlineRetailerOrderSubmitJob.OnlineRetailerOrderSubmitJob.JobMain(IJobContext jobContext)
    [13468] [1] DEBUG TrueValue.Fry.Jobs.Host.Program - Finished Job OnlineRetailerOrderSubmitJob
    Process terminating normally, creating success flag file.
    Process Terminating: 0
    Job retcode=0
    Success Flag found, setting retcode=0

    We can achieve some level of exception using FILTER object however my concern is what if the error changes in upcoming executions.
    So, FILTER object is our last resort. before that could someone please suggest what is wrong here and how we can capture the error without using FILTER Object.


    Thanks in Advance
    Shani



  • 2.  RE: Error Handling in jobs

    Posted Aug 02, 2019 01:24 AM
    Check the executions statistic record for the returncode value of that run. I have seen applications on Windows that returned negative return code values. If this is the case, you can amend the expected returncode from the default 0 to -1 in the job settings.

    ------------------------------
    Swisscom & WorkflowCommander
    ------------------------------



  • 3.  RE: Error Handling in jobs

    Posted Aug 20, 2019 02:29 PM
    Regarding negative return codes out of .net apps, we execute this statement to take the absolute value of the return code.

    @if %retcode% lss 0 set /a retcode=%retcode%*-1

    ------------------------------
    Pete
    ------------------------------