Author |
Message
|
sasad |
Posted: Fri May 09, 2014 5:27 am Post subject: How to add variables into Environment? |
|
|
Acolyte
Joined: 30 Apr 2014 Posts: 67
|
Hi all,
I have developed a message flow in which I reads File from FTP using FileInput node, parse it record by record and if it record gets parsed successfully insert it into database. If not then create a log for it. After complete processing of File I want to create an log file for audit purpose. In which I want to show name of File, total records, Parsed records without errors and those with errors.
I have attached Trace node on the End of Data terminal of FileInput node. I am able to fetch file related information from LocalEnvironment but how can I maintain the number of passed and failed records?
I tried it by attaching compute node on Failure terminal of FileInput node, and adding a new variable for failed count, but that variable is not appearing on End of Data. |
|
Back to top |
|
 |
Vitor |
Posted: Fri May 09, 2014 5:48 am Post subject: Re: How to add variables into Environment? |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sasad wrote: |
how can I maintain the number of passed and failed records? |
Use a shared variable and maintain a count. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sasad |
Posted: Fri May 09, 2014 5:58 am Post subject: |
|
|
Acolyte
Joined: 30 Apr 2014 Posts: 67
|
I am new to broker can you please share an example. I tried as below but it didn't worked.
SET OutputRoot.XMLNSC.SHARE.COUNT = 1; |
|
Back to top |
|
 |
sasad |
Posted: Fri May 09, 2014 6:46 am Post subject: |
|
|
Acolyte
Joined: 30 Apr 2014 Posts: 67
|
Well, I was able to create a Shared Variable. What I have notice in debug is that this shared variable appears only when I am under any Compute node.
I want to print value of this shared variable in a Trace. Can someone tell me how to print it to trace.
DECLARE Count SHARED INTEGER 0;
Trace Node Properties
Pattern : Failed Records : ${Environment.Count}
OR
Pattern : Failed Records : ${Count} |
|
Back to top |
|
 |
McueMart |
Posted: Fri May 09, 2014 8:01 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
I dont think you can access shared variables directly from within a Trace node (Someone will be along to correct me if i'm wrong!). What you can do is assign the value into the Environment tree in Compute node which comes before your trace node e.g.
SET Environment.Count = Count;
And then in your Trace node
${Environment.Count} should work.
If you are new to broker, one of the things you need to learn quickly is the different parts of the logical message assembly - these are:
- Root (i.e. Input/Output Root)
- Environment
- LocalEnvironment
- ExceptionList
Dont get these confused with SHARED variables. They are totally different things. |
|
Back to top |
|
 |
Vitor |
Posted: Fri May 09, 2014 8:21 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sasad wrote: |
I want to print value of this shared variable in a Trace. Can someone tell me how to print it to trace. |
a) You can't
b) You shouldn't use Trace node for anything other than debugging (like writing audit records). Aside from the overhead, if your broker administrator decides to switch off trace in your production environment to make it go faster, your audit function will stop working.
Extract the values with a Compute node then write them out with a FileOutput node. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sasad |
Posted: Fri May 09, 2014 8:52 am Post subject: |
|
|
Acolyte
Joined: 30 Apr 2014 Posts: 67
|
Thanks alot guys!!! Specially Vitor for the suggestion. |
|
Back to top |
|
 |
|