|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
ESQL vs Java (MBelement) |
« View previous topic :: View next topic » |
Author |
Message
|
Gama |
Posted: Wed Feb 27, 2013 10:15 am Post subject: ESQL vs Java (MBelement) |
|
|
 Centurion
Joined: 11 Jan 2005 Posts: 103 Location: Portugal
|
I'm in trouble with message broker and java, so could any one help me?
Resuming i need to call a Java method from ESQL, that one of the parameter is INOUT with the MBelement type
After consulting ESQL-to-Java data-type documented in ("http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.wmb_v6/wmb/6.0/ApplicationDevelopment/ESQL_Capabilities/Ext_Functions_Java/player.html") mapping table I need to pass a ESQL referece (Message Tree) to Java to be updated from Java method an then returned back to ESQL to continue the flow.
I think is possible or no?
ESQL Code:
Quote: |
SET OutputLocalEnvironment.VAR1.AAA = '1234';
SET OutputRoot.XML.VAR2.AAA = '1';
SET OutputRoot.XML.VAR2.AAB = '2';
SET OutputRoot.XML.VAR2.AAC = '3';
CALL MBelement01(OutputLocalEnvironment.VAR1.AAA, OutputRoot.XML.VAR2);
CREATE PROCEDURE MBelement01(IN P1 CHAR, INOUT refVar REFERENCE)
LANGUAGE JAVA
EXTERNAL NAME "ls.mbelement.Test_MBelement.CallMBelement01"; |
Java Code:
Quote: |
package ls.mbelement;
import com.ibm.broker.plugin.MbElement;
/**
* @author NRGama
*
*/
public class Test_MBelement {
public static void CallMBelement01(String lang, MbElement[] mbe) {
}
}
|
I always receve the follow error:
Quote: |
RecoverableException
Text:CHARACTER:Error detected, rethrowing
Insert
Type:INTEGER:5
Text:CHARACTER:Java.javaCall01_Call_Java01.Main
Insert
Type:INTEGER:5
Text:CHARACTER:12.3
Insert
Type:INTEGER:5
Text:CHARACTER:MBelement01(OutputLocalEnvironment.VAR1.AAA, OutputRoot.XML.VAR2.AAA);
RecoverableException
File:CHARACTER:F:\build\slot2\S800_EP\src\DataFlowEngine\ImbRdl\ImbRdlRoutine.cpp
Line:INTEGER:2477
Function:CHARACTER:SqlRoutine::clearDownChildEnv
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2933
Text:CHARACTER:
Insert
Type:INTEGER:5
Text:CHARACTER:refVar |
Any ideas?
Thanks |
|
Back to top |
|
 |
adubya |
Posted: Wed Feb 27, 2013 10:34 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
When invoking, try
Code: |
SET OutputLocalEnvironment.VAR1.AAA = '1234';
SET OutputRoot.XML.VAR2.AAA = '1';
SET OutputRoot.XML.VAR2.AAB = '2';
SET OutputRoot.XML.VAR2.AAC = '3';
DECLARE testRef REFERENCE TO OutputRoot.XML.VAR2;
CALL MBelement01(OutputLocalEnvironment.VAR1.AAA, testRef );
|
|
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Feb 27, 2013 9:38 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Generally an IN will be enough. Reference type in Java is I believe MbElement.
With more insight into your code you will get more specific answers...
So the java signature should be:
mymethod(String mystringval, MbElement sometreeref)
And in ESQL
CREATE PROCEDURE myproc( IN myvalue CHARACTER, IN myref REFERENCE) language....
Note you should only use INOUT on a ref if you cannot solve the problem with IN only.(i.e. you are returning a reference that points to somewhere else).
Have some fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Gama |
Posted: Thu Feb 28, 2013 7:13 am Post subject: |
|
|
 Centurion
Joined: 11 Jan 2005 Posts: 103 Location: Portugal
|
Hi,
Tkanks a lot to both fo you, I got it.
ESQL
Quote: |
SET OutputLocalEnvironment.VAR1.AAA = '1234';
SET OutputLocalEnvironment.MBelement.VAR2 = '#';
SET OutputLocalEnvironment.MBelement.VAR2[1].a = '##';
SET OutputLocalEnvironment.MBelement.VAR2[1].b = '###';
SET OutputLocalEnvironment.MBelement.VAR2[2].a = '####';
SET OutputLocalEnvironment.MBelement.VAR2[2].b = '#####';
DECLARE xmlRef REFERENCE TO OutputLocalEnvironment.MBelement;
|
JAVA
Quote: |
public static void CallMBelement01(String lang, MbElement[] mbe) {
try { MbElement m = mbe[0].getFirstChild();
String a;
a = m.getName();
mbe[0].createElementAsFirstChild(MbElement.TYPE_NAME, "AA", "a1");
mbe[0].createElementAsLastChild(MbElement.TYPE_NAME, "AB", "a2");
} catch (MbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
Many thaks. |
|
Back to top |
|
 |
nits_018 |
Posted: Sat Mar 02, 2013 5:14 am Post subject: Need code snippet and help for the same |
|
|
Apprentice
Joined: 24 Oct 2012 Posts: 34
|
@gama Will the above function works if we defined the Ref to Output root instead of Output Local Environment..just curious to know and of no can you tell the exact reason for the same. |
|
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
|
|
|
|