Author |
Message
|
5zan |
Posted: Fri Jul 18, 2008 8:25 am Post subject: try catch implementation by esql POSSIBLE ?? |
|
|
Novice
Joined: 08 Jul 2008 Posts: 24
|
I AM CALLING A JAVA METHOD FOR AUDITING IN MY MESSAGE FLOWS .
the requiremnt is that even if i encounter an error in this call or the java method fails , i want to ignore the exception and the flow shouldnt roll back ..
it just like what we do with the try catch block ..
can i hold the exception and ignore it , therby continuing with the flow processing even if the auditing fails or exception list generated ??
Any tricks ?
 |
|
Back to top |
|
 |
sridhsri |
Posted: Fri Jul 18, 2008 8:29 am Post subject: |
|
|
Master
Joined: 19 Jun 2008 Posts: 297
|
While this may not be the recommended approach, you could catch all your exceptions in the java code and do nothing no it. This way, the compute wont realize something went wrong with the java call. |
|
Back to top |
|
 |
5zan |
Posted: Fri Jul 18, 2008 8:36 am Post subject: |
|
|
Novice
Joined: 08 Jul 2008 Posts: 24
|
Appreciate yr response , but what if the whole thing is in ESQL only , what can be done in such a case ? |
|
Back to top |
|
 |
sridhsri |
Posted: Fri Jul 18, 2008 8:40 am Post subject: |
|
|
Master
Joined: 19 Jun 2008 Posts: 297
|
Then I'm afraid the only solution I can think of is using the trycatch node before the compute. You may choose not to use a throw node in the catch terminal of that node. That way broker wont think anything went wrong. You could wire the catch terminal the next processing node in your flow. |
|
Back to top |
|
 |
kimbert |
Posted: Sat Jul 19, 2008 2:34 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
sridhsri |
Posted: Sat Jul 19, 2008 7:04 am Post subject: |
|
|
Master
Joined: 19 Jun 2008 Posts: 297
|
That is great info!
But I was wondering if those handlers are only applicable to SQL Statements to trap SQL Errors. If that is indeed the case, then I don't know if this solution would work 5zan because 5zan was invoking Java from ESQL. |
|
Back to top |
|
 |
kimbert |
Posted: Sat Jul 19, 2008 9:14 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I was wondering if those handlers are only applicable to SQL Statements to trap SQL Errors |
No, they can catch any exception at all. The page which I linked talks about SQL rather than ESQL. I may put a comment on it and suggest that the wording is improved. |
|
Back to top |
|
 |
sridhsri |
Posted: Sat Jul 19, 2008 9:30 am Post subject: |
|
|
Master
Joined: 19 Jun 2008 Posts: 297
|
This is great!
You are right, the wordings are a little misleading - esp. the following wordings:
Quote: |
If there are no exceptions, the presence of handlers has no effect on the behavior or performance of an SQL program. If an exception occurs, WebSphere® Message Broker compares the SQL state of the exception with the SQL states associated with any relevant handlers, until either the exception leaves the node (just as it would if there were no handlers) or a matching handler is found. |
If i may also suggest, perhaps we can add an example showing non-SQL and have SQLSTATE as optional param in the syntax. |
|
Back to top |
|
 |
sridhsri |
Posted: Sat Jul 19, 2008 11:37 am Post subject: |
|
|
Master
Joined: 19 Jun 2008 Posts: 297
|
I was also wondering if these exception handlers would work for calling java from ESQL. |
|
Back to top |
|
 |
5zan |
Posted: Sun Jul 20, 2008 10:10 pm Post subject: |
|
|
Novice
Joined: 08 Jul 2008 Posts: 24
|
Thanx kimbert ,
Even i was wondering if it can work for any ESQL ?
Can i encapsulate a Java method call b/w the handler .. if yes can u tell me how ? i can only see SQL states being referred in the link !  |
|
Back to top |
|
 |
kimbert |
Posted: Mon Jul 21, 2008 4:37 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Here are the facts:
- DECLARE HANDLER can catch any and all broker exceptions. You control which ones you want to catch using the LIKE clause.
- When the docs talk about 'SQL state' they mean one of the states returned by SQLSTATE, as listed here http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ak17990_.htm.
- You *can* catch java errors using DECLARE HANDLER...but there are special rules to remember...
- You cannot call ( direct from ESQL ) any Java method which throws a non-fatal exception. The JVM might still throw an out-of-memory exception, or something like that. So you should not expect to be able to catch your own java exceptions.
- You can PROPAGATE from ESQL to a named terminal. If that terminal is connected to a JavaCompute node, then you can throw a Java exception from that JavaCompute node, and catch it with an ESQL handler. You might need to examine the SQLSTATE in the handler code to work out what sort of exception you have caught.
Hope that helps. |
|
Back to top |
|
 |
|