Author |
Message
|
bkteoh |
Posted: Sun Oct 14, 2012 11:16 pm Post subject: Dynamic message logging |
|
|
Newbie
Joined: 14 Oct 2012 Posts: 2
|
Hi all,
I am trying to implement dynamic message logging.
I have a database table that stores below.
SERVICE_NAME | COL1 | COL2
==============================================================================
GETCUSTOMER | InputRoot.XMLNSC.LOGMSG.CUST.NAME | InputRoot.XMLNSC.LOGMSG.CUST.SSN
During runtime, I will select the appropriate message element to be logged based on service name from the table above. This values should refer to the actual element in the message tree.
Based on the input XML. I was expecting the actual values to be stored.
<LOGMSG>
<CUST>
<NAME>XXXX</NAME>
<SSN>YYYY</SSN>
</CUST>
</LOGMSG>
Instead, BROKER will store the values as is - InputRoot.XMLNSC.LOGMSG.CUST.NAME and InputRoot.XMLNSC.LOGMSG.CUST.SSN to the LOG_TBL table.
I've tried various ways but to no avail.
1) APPROACH 1
INSERT INTO Database.LOG_TBL(C1, C2)
VALUES(Environment.Variables.CONFIG[1].COL1, Environment.Variables.CONFIG[1].COL2);
2) APPROACH 2
DECLARE refcol1 REFERENCE TO Environment.Variables.CONFIG[1].COL1;
DECLARE refcol2 REFERENCE TO Environment.Variables.CONFIG[1].COL2;
INSERT INTO Database.LOG_TBL(C1, C2) VALUES(refcol1, refcol2)
Could anyone shed some light on the above.
Environment:
WebSphere Message Broker V8
AIX 6.1
Thank you. |
|
Back to top |
|
 |
Gemz |
Posted: Sun Oct 14, 2012 11:48 pm Post subject: |
|
|
 Centurion
Joined: 14 Jan 2008 Posts: 124
|
Hi bktoeh,
Try with EVAL function to get the value from XPATH...
Code: |
INSERT INTO Database.LOG_TBL(C1, C2)
VALUES(EVAL(Environment.Variables.CONFIG[1].COL1), EVAL(Environment.Variables.CONFIG[1].COL2)); |
_________________ GemZ
"An expert is one who knows more and more about less and less until he knows absolutely everything about nothing...." |
|
Back to top |
|
 |
McueMart |
Posted: Mon Oct 15, 2012 12:51 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
What does your SET statement look like when you are setting the values of
Code: |
Environment.Variables.CONFIG[1].COL1
Environment.Variables.CONFIG[1].COL2 |
? |
|
Back to top |
|
 |
bkteoh |
Posted: Mon Oct 15, 2012 2:23 am Post subject: |
|
|
Newbie
Joined: 14 Oct 2012 Posts: 2
|
Gemz wrote: |
Hi bktoeh,
Try with EVAL function to get the value from XPATH...
Code: |
INSERT INTO Database.LOG_TBL(C1, C2)
VALUES(EVAL(Environment.Variables.CONFIG[1].COL1), EVAL(Environment.Variables.CONFIG[1].COL2)); |
|
Hi Gemz,
Your suggestion worked. It is getting the actual values now.
Million thanks. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Oct 15, 2012 2:47 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
EVAL is costly in CPU.
I would personally solve this problem by storing an XPath expression instead of an ESQL path, and then using a short Java procedure to evaluate the XPath against the message tree.
I do not claim this is less costly in CPU.
I would consider using SELECT in ESQL instead of using EVAL to resolve the field references. I do not claim that I've done this, however. |
|
Back to top |
|
 |
Gemz |
Posted: Mon Oct 15, 2012 3:11 am Post subject: |
|
|
 Centurion
Joined: 14 Jan 2008 Posts: 124
|
Hi mqjeff,
Since the XPATH is in config table and it varies for each SERVICE_NAME.
Any hints to use SELECT instead of EVAL? _________________ GemZ
"An expert is one who knows more and more about less and less until he knows absolutely everything about nothing...." |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Oct 15, 2012 3:18 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Gemz wrote: |
Hi mqjeff,
Since the XPATH is in config table and it varies for each SERVICE_NAME.
Any hints to use SELECT instead of EVAL? |
Yes, you would populate the config table with the xpath expression and then pass that into your java procedure.
As I said, I've not tried using SELECT to do this kind of thing, but it strikes me as *possible*. Something vaguely like
Code: |
select Environment.Variables.CONFIG[1].COL1,Environment.Variables.CONFIG[1].COL2 from InputRoot |
But thinking about it a bit more, that probably won't work. ESQL select always needs a database reference, so it would have to be something like "T.Environment.Variables.CONFIG[1].COL1" and that won't parse. Never mind. |
|
Back to top |
|
 |
|