|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Capture external Java procedure exception inside Flow ESQL |
« View previous topic :: View next topic » |
Author |
Message
|
sunny_30 |
Posted: Fri Jun 06, 2014 8:25 pm Post subject: Capture external Java procedure exception inside Flow ESQL |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
I have a message flow invoking external Java procedure. If an exception occurs in the Java, the error string needs to be captured inside Flow ESQL.
I set the Java procedure to be executed inside ESQL Handler block, so when an exception occurs, its invoking another Java method which returns the error string in a static variable (I cannot use an instance variable since the external function has to be static). This approach works but all isnt well.
In heavy traffic, the static (EG JVM scope) variable data is getting overwritten by another instance. Can someone please suggest a solution ? Thank you |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jun 06, 2014 10:28 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you thought about using a ThreadLocal variable to make it thread safe?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kash3338 |
Posted: Sat Jun 07, 2014 5:54 am Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Jun 07, 2014 11:01 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You are forgetting that java.lang.String is not a primitive and that it as such it would not qualify... maybe as a reference... and then what's the incessant stuff with internal loops?
Better in this particular case to use a ThreadLocal variable... as you want each thread to have it's own copy and not change/see the value of a different thread...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
sunny_30 |
Posted: Sun Jun 08, 2014 12:27 am Post subject: |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
Thank you both for the Help. Implemented ThreadLocal. Tried Atomic as well, little complicated but it seems to work as well
Apart from capturing exceptions, there was another issue I was able to fix using ThreadLocal. JDBC connection value was stored as JCN static variable (not threadsafe) accessed from another class where external JDBC methods are defined, invoked using ESQL. I couldn't merge JCN class and the JDBC methods class. All external methods, variables involved had to be defined as static, otherwise not working. ThreadLocal helped keep the JDBC connections local to the flow thread. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|