|JAVA how to handle the exceptions in control-M
|Page 1 of 1|
|Author:||janum [ 04 May 2007 5:16 ]|
|Post subject:||JAVA how to handle the exceptions in control-M|
I have configured Control-M BPI suite 6.3.01 and java server is Tomcat.
We are able to trigger the jobs in tomcat server.
Always jobs return with success .
Looks like Control-M is getting OSCOMPSTAT as 0 always...
I am calling a simple method which returns 1 when exception occurs.
for me it is failure, but control-M completed job with Ok status..
Any one using control-M for java , please help me...
|Author:||dkadosh [ 16 May 2007 3:19 ]|
|Post subject:||Java class Control-M jobs fail if an exception was thrown.|
Simple answer: Java class Control-M jobs fail if an exception was thrown.
A java type batch job (POJO) means running any method inside a java class.
The method can return any type of a parameter like more primitive types: int, char, strings, etc... or it can also return a complex class like date, employee, myClass,...
If a complex class is part of the Java account classpath, and it has a toString method, than toString will be in the sysout.
Q how does a Java job succeed?
A: If the method returned the return parameter, than the Job will succeed (the job will appear in Green color)
So in your case you have a method that returns an integer number. Any number is valid, and the job will succeed.
Q: How does a java job fail?
A: if an exception is thrown.
So if you want to indicate Control-M that the job failed, throw an exception instead of returning a value.
The exception will appear in the sysout.
Another alternative to throwing an exception is to do post processing to the sysout. So if you know that if you see in the sysout that the job returned 1 and it means failure, you can do post processing, and mark the job as failed.
|Author:||janum [ 21 May 2007 4:05 ]|
Thanks dkadosh! for your valuable suggestions...
I have tested successfully exception/postprocessing method.
|Author:||poojagite [ 05 Feb 2019 8:04 ]|
|Post subject:||Re: JAVA how to handle the exceptions in control-M|
control-M for Web Services ,Java and Messaging (WJM, formerly BPI) allows Control-M to run Java applications.
Simply returning the code (0 or 1 or whatever) is not enough to determine whether the job actually fails or succeeds:
1Java methods can return any type of value which can have any meaning the developer wants. Best practice for Java programming is to use Exception handling if there is a failure. For more information, please refer to following link:
2. The Control-M Java CM (the caller) is a generic invoker and it does not know the meaning of the returned value from Java methods. So long as the invokation of the Java method was successful and there was no Exception thrown, then the CM will assume the job is OK.
If you would like Control-M to declare that the invokation should return NOTOK if the actual Java application fails, then you can do any of the followings:
a) Have your method returns a string, such as "Invokation failed". Then, add ON STMT processing to the CM job definition to declare job as NOTOK when encountering the "Invokation failed" statement.
b) Have your Java method thrown an Exception if it fails.
c) Place the method logic in the main() function with a call to System.exit(1) and set the CM job definition to invoke the main() method instead.
https://crbtech.in/java-training/top-ja ... nt-in-pune
|Page 1 of 1||All times are UTC+01:00|
|Powered by phpBB® Forum Software © phpBB Limited