on 12-21-2011 10:18 AM
Lets say we get an exception in the module but instead of erroring out the channel, we need to pass an information log and stop the message from further being processed.
Any idea how can we achieve this?
Currently we are trying to do some checks within a module and in case of the failure to stop further processing of the message we are forced to raise a module exception but it leads to the channel going into error status and triggering alerts.
What we need is to have the channel still in green and stop the message processing with just passing an info message in the adapter log.
Hi Shabz,
I have tried similar kind of solution in adapter module but no luck, we can avoid catching exception in module but not possible to stop the message processing.
hence decided handle exception in module and thrown exception .
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>Currently we are trying to do some checks within a module and in case of the failure to stop further processing of the message we are forced to raise a module exception but it leads to the channel going into error status and triggering alerts
IMO, the following way of handling the logic seems better... Please dont use exit or break statement unless you are intent to..
exit operation will totally stop your current thread. Dont want to do that. Break statement is intended to stop the loop operation.
Though exception handling is better for the filtering out the dangerous events to proceed further, it is also possible to ignore exceptions in the following ways.
try{
//application logic
}
catch(Exception e){
// ignore exception logic.. That means dont catch or throw the exception to the exception handler for the exception chain loop.
// i.e means don't implement any logic here. But you can use logtrace as follows
e.printStackTrace(); // this would log errors but not throw the exception.
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
well guys the problem is if you handle the exception at the module level, we dont seem to have control on stopping the flow to proceed with only an info message logged.
Seems the exceptions handled at the module level leads to an error log and then the processing stops.
What we wanted to do was stop the processing but not put the adapter into an error status
>What we wanted to do was stop the processing but not put the adapter into an error status
First we need reason or event for stop processing the adapter module logic, so you create some specific business exception pertain to that and then if the error occurs you might want to catch that exception first and inside the catch block don't use log traces for those errors and use just break statement to come out of that loop to stop execute the try logic.
>>Seems the exceptions handled at the module level leads to an error log and then the processing stops
That's logical. Therefore I was suggesting if/else and break/exit.
>> if the error occurs you might want to catch that exception first
I guess this will lead to error status.
Haven't written java code since some time now but instead of throwing a generic expception, is it possible to handle it in if-else?
And, why is this strange requirement came up?
Regards,
Prateek Raj Srivastava
>>we are forced to raise a module exception
I guess it is a custom module and you are throwing the exception in java. Have you tried to check the exception code and add it under if/else to avoid throwing exception? If you manage to get your execution to if/else block, then you can use some command like exit or break (long time since I did java coding) to end that module execution. May be in that block you can add a code to pass an empty file to next module chain and if you are using file adapter, just ignore empty file.
Just thinking loud
Regards,
Prateek Raj Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.