Author |
Message
|
nukalas2010 |
Posted: Tue Oct 05, 2010 1:37 am Post subject: Issue of LOG4J using ESQL |
|
|
 Master
Joined: 04 Oct 2010 Posts: 220 Location: Somewhere in the World....
|
Hi friends..
In my Message Flow I am using MQinput,Compute,Log4j and Mqoutput Nodes Respectively..
In COmpute Node I mentioned the Code as follows:
CREATE FUNCTION initLog4j( IN CONFIG_FILE_NAME CHARACTER )
RETURNS BOOLEAN
LANGUAGE JAVA
EXTERNAL NAME "com.ibm.broker.IAM3.Log4jNode.initLog4j";
CREATE FUNCTION log4j( IN COMPONENT_NAME CHARACTER,
IN LEVEL CHARACTER,
IN TEXT CHARACTER)
RETURNS BOOLEAN
LANGUAGE JAVA
EXTERNAL NAME "com.ibm.broker.IAM3.Log4jNode.log";
CREATE COMPUTE MODULE Log4jESQLMsgFlow_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
CALL CopyEntireMessage();
DECLARE rc BOOLEAN;
CALL initLog4j('C:\Documents and Settings\freeuser\Desktop\broker.xml') INTO rc;
set InputLocalEnvironment.Log4jvalues = InputRoot.XMLNS.Details.Name || InputRoot.XMLNS.Details.Surname;
CALL log4j('Log4jESQLMsgFlow.msgflow', 'WARN','$ESQL:InputLocalEnvironment.Log4jvalues$') INTO rc;
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
--SET Environment.Variables.Log4j.LogText='My Message is $ESQL:InputRoot.XMLNS.Test.Part.ex$';
END;
END MODULE;
My InputMessage is like this
<Details><Name>greencity</Name><Surname>bangalore</Surname><xyz>fdd</xyz></Details>
using this code I am getting output as follows: My Message is greencity
But I want the output message as follows:
My Mesage is greencitybangalore
Can u please help me to find out  |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Oct 05, 2010 2:01 am Post subject: Re: Issue of LOG4J using ESQL |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
From the code provided I cant see how you can output:
nukalas2010 wrote: |
My Message is greencity
|
Are you sure this is the correct code snippet for this output or is there some other salient piece of information thats missing? |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Oct 05, 2010 2:26 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Code: |
set InputLocalEnvironment.Log4jvalues = InputRoot.XMLNS.Details.Name || InputRoot.XMLNS.Details.Surname;
|
|
|
Back to top |
|
 |
nukalas2010 |
Posted: Tue Oct 05, 2010 2:40 am Post subject: |
|
|
 Master
Joined: 04 Oct 2010 Posts: 220 Location: Somewhere in the World....
|
yeah actually... I defined the properties for Log4j Node as follows:
Log4jConfigfile: C:\Documents and Settings\ngiuser\Desktop\broker.xml
LogLevel: WARN
LogText: My Message is $ESQL:InputRoot.XMLNS.Details$
LoggerName: default
Here is my Input file:
Quote: |
<Details><Name>greencity</Name><Surname>bangalore</Surname><xyz>fdd</xyz></Details>
|
as per the above input message I am getting the output as My Message is greencity
but If I want the output message as
My Message is greencity fdd
what are the changes that I have to do in that Code... |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Oct 05, 2010 2:45 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
mqjeff wrote: |
Code: |
set InputLocalEnvironment.Log4jvalues = InputRoot.XMLNS.Details.Name || InputRoot.XMLNS.Details.Surname;
|
|
It was the "My Message is" (the bit I put in bold) that I didnt get and was confused as the code supplied had a line with this in commented out, it was this I wanted to check |
|
Back to top |
|
 |
nukalas2010 |
Posted: Tue Oct 05, 2010 2:49 am Post subject: |
|
|
 Master
Joined: 04 Oct 2010 Posts: 220 Location: Somewhere in the World....
|
Hi mqj..
In my code I mentioned this line
Quote: |
set InputLocalEnvironment.Log4jvalues = InputRoot.XMLNS.Details.Name || InputRoot.XMLNS.Details.Surname; |
because I want the output message as subparts.. like My message is greencity bangalore
that means if suppose if I mentined the code line as follows:
Quote: |
set InputLocalEnvironment.Log4jvalues = InputRoot.XMLNS.Details.Name;
|
I got the o/p message as My message is greencity
if supposee I want the output message as My message is greencity fdd
what are the changes that I have to do in the code as previously written..
 |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Oct 05, 2010 2:49 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
nukalas2010 wrote: |
LogText: My Message is $ESQL:InputRoot.XMLNS.Details$ |
|
|
Back to top |
|
 |
mqjeff |
Posted: Tue Oct 05, 2010 2:51 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You need to write code to construct the message in the way you want to construct the message.
Since it appears that Log4J is expecting a string, then you need to write code to construct a string that is formatted the way you want it to be.
Using || is a good start. |
|
Back to top |
|
 |
nukalas2010 |
Posted: Tue Oct 05, 2010 3:15 am Post subject: |
|
|
 Master
Joined: 04 Oct 2010 Posts: 220 Location: Somewhere in the World....
|
yeah thanku mqjeff .. but I dnt have any Idea how to do it..
can you please send in detail.. |
|
Back to top |
|
 |
nukalas2010 |
Posted: Tue Oct 05, 2010 8:32 pm Post subject: |
|
|
 Master
Joined: 04 Oct 2010 Posts: 220 Location: Somewhere in the World....
|
Hiii Friends...
I do some modifications in ESQL Code as follows to get the output as I required:
For LOG4J Node I set the properties as below:
LogText: An Environment value: $Environment$
My Input Message is:
Quote: |
<Details><Name>greencity</Name><Surname>bangalore</Surname><xyz>fdd</xyz></Details>
|
The ESQL Code is:
Quote: |
CALL CopyEntireMessage();
DECLARE key1 CHARACTER FIELDNAME(InputRoot.XMLNS.Details.Name);
DECLARE value1 CHARACTER InputRoot.XMLNS.Details.Name;
DECLARE key2 CHARACTER FIELDNAME(InputRoot.XMLNS.Details.Surname);
DECLARE value2 CHARACTER InputRoot.XMLNS.Details.Surname;
set Environment.Variables= key1 ||':'||value1||',' ||key2||':'||value2;
|
I am getting the Output as follows:
Quote: |
10:23:18,843 WARN [SampleLog.Log4jESQLMsgFlow] An Environment value: Name:greencity,Surname:bangalore
|
But I dnt want to use as Environment.. I want as Local Environment..
can u people help me how to do it?? :hellp: |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Oct 05, 2010 10:50 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
nukalas2010 wrote: |
But I dnt want to use as Environment.. I want as Local Environment..
can u people help me how to do it?? :hellp: |
Would you care to explain why you don't want to use Environment?
It is there for you to use after all. It also stays with you without having to copy it for the life of a message as it is being processed.
Is it because the following node needs data in the LocalEnvironment? If so then fine.
Back to your question.
Have you tried substituting OutputLocalEnvironment for Environment?
Remember, in the next node where the LocalEnvironment is accessible you may have to read from it use InputLocalEnvironment.
In my experience, I tend towards using the LocalEnvironment only where the following node needs that folder as data. For example dynamically specifying a Queue Name to an MQOutput Node, or data for the EMailOutput Node. I think it provides a cleaner data set in the long run. But that is only my opinion hence my asking why you want to use LocalEnvironment. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
nukalas2010 |
Posted: Thu Oct 07, 2010 3:00 am Post subject: |
|
|
 Master
Joined: 04 Oct 2010 Posts: 220 Location: Somewhere in the World....
|
Quote: |
In my experience, I tend towards using the LocalEnvironment only where the following node needs that folder as data |
me too wanna use LocalEnvironment only.. |
|
Back to top |
|
 |
|