Author |
Message
|
visasimbu |
Posted: Sat Aug 03, 2013 6:27 am Post subject: File Read Node record number update |
|
|
 Disciple
Joined: 06 Nov 2009 Posts: 171
|
Version - WMB7.0.0.4
I have message flow with below format.
MQInputnode -> Compute Node1 -> FileRead node -> Compute Node2.
Here I have to read a file. It has a size more than a 10 MB. I am setting a property for fileread node as fixed length option and size as 5MB for each record.
I have to do some manipulation for the first record alone. So I am looking for the below path to determine whether it is first record or not in the compute node2.
Code: |
InputLocalEnvironment.File.Read.RecordNumber; |
But I am always getting integer '1' from the above path which means that for the second chunk message also record number is '1'.
Could you please, tell me why the value of 'RecordNumber' is always '1' ? |
|
Back to top |
|
 |
dogorsy |
Posted: Sat Aug 03, 2013 6:34 am Post subject: Re: File Read Node record number update |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
visasimbu wrote: |
Version - WMB7.0.0.4
I have message flow with below format.
MQInputnode -> Compute Node1 -> FileRead node -> Compute Node2.
Here I have to read a file. It has a size more than a 10 MB. I am setting a property for fileread node as fixed length option and size as 5MB for each record.
I have to do some manipulation for the first record alone. So I am looking for the below path to determine whether it is first record or not in the compute node2.
Code: |
InputLocalEnvironment.File.Read.RecordNumber; |
But I am always getting integer '1' from the above path which means that for the second chunk message also record number is '1'.
Could you please, tell me why the value of 'RecordNumber' is always '1' ? |
you need to add more detail if you want help. I guess the flow is triggered by a message put into the queue. That will cause the file read node to read the first record from the file. What happens next ? How do you get the flow to read subsequent records ? |
|
Back to top |
|
 |
kash3338 |
Posted: Sat Aug 03, 2013 6:39 am Post subject: Re: File Read Node record number update |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
visasimbu wrote: |
Could you please, tell me why the value of 'RecordNumber' is always '1' ? |
This is what the info center says about this here
Quote: |
The number of the record in the file relative to the offset the read node starts reading from. The value is always 1 unless the filter expression is being used, in which case it reflects the number of the record that was selected. |
|
|
Back to top |
|
 |
visasimbu |
Posted: Sat Aug 03, 2013 7:44 am Post subject: Re: File Read Node record number update |
|
|
 Disciple
Joined: 06 Nov 2009 Posts: 171
|
kash3338 wrote: |
visasimbu wrote: |
Could you please, tell me why the value of 'RecordNumber' is always '1' ? |
This is what the info center says about this here
Quote: |
The number of the record in the file relative to the offset the read node starts reading from. The value is always 1 unless the filter expression is being used, in which case it reflects the number of the record that was selected. |
|
Thanks Kashyap ! you routed me to exactly what I want.
But what filter expression is needed by broker to make the Record number as incremental ? |
|
Back to top |
|
 |
visasimbu |
Posted: Sat Aug 03, 2013 7:51 am Post subject: Re: File Read Node record number update |
|
|
 Disciple
Joined: 06 Nov 2009 Posts: 171
|
dogorsy wrote: |
you need to add more detail if you want help. I guess the flow is triggered by a message put into the queue. That will cause the file read node to read the first record from the file. What happens next ? How do you get the flow to read subsequent records ? |
FileRead node populates the some values in the local environment (as specified in below fields). In that record number is always '1' for me. What is the reason for this behaviour ?
Code: |
LocalEnvironment.File.Read.Directory
LocalEnvironment.File.Read.Name
LocalEnvironment.File.Read.LastModified
LocalEnvironment.File.Read.TimeStamp
LocalEnvironment.File.Read.Offset
LocalEnvironment.File.Read.NextRecordOffset
LocalEnvironment.File.Read.EndOfFile
LocalEnvironment.File.Read.RecordNumber
.. etc.. |
|
|
Back to top |
|
 |
dogorsy |
Posted: Sat Aug 03, 2013 7:59 am Post subject: Re: File Read Node record number update |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
visasimbu wrote: |
dogorsy wrote: |
you need to add more detail if you want help. I guess the flow is triggered by a message put into the queue. That will cause the file read node to read the first record from the file. What happens next ? How do you get the flow to read subsequent records ? |
FileRead node populates the some values in the local environment (as specified in below fields). In that record number is always '1' for me. What is the reason for this behaviour ?
Code: |
LocalEnvironment.File.Read.Directory
LocalEnvironment.File.Read.Name
LocalEnvironment.File.Read.LastModified
LocalEnvironment.File.Read.TimeStamp
LocalEnvironment.File.Read.Offset
LocalEnvironment.File.Read.NextRecordOffset
LocalEnvironment.File.Read.EndOfFile
LocalEnvironment.File.Read.RecordNumber
.. etc.. |
|
you have not answered the question. How do you get the flow to read all the records in the file ? |
|
Back to top |
|
 |
visasimbu |
Posted: Sat Aug 03, 2013 8:06 am Post subject: Re: File Read Node record number update |
|
|
 Disciple
Joined: 06 Nov 2009 Posts: 171
|
dogorsy wrote: |
you have not answered the question. How do you get the flow to read all the records in the file ? |
I have set below properties in compute node1
Code: |
SET OutputLocalEnvironment.Destination.File.Directory = Directory;
SET OutputLocalEnvironment.Destination.File.Name = '*'||FileName_withtimestamp;
SET OutputLocalEnvironment.Destination.File.WildCard = '*';
SET OutputLocalEnvironment.Destination.File.Offset = Environment.Variables.NextRecordOffset; |
As mentioned in the above thread, I am reading a file as fixed length by setting appropriate properties in FileRead node. |
|
Back to top |
|
 |
dogorsy |
Posted: Sat Aug 03, 2013 8:14 am Post subject: Re: File Read Node record number update |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
visasimbu wrote: |
dogorsy wrote: |
you have not answered the question. How do you get the flow to read all the records in the file ? |
I have set below properties in compute node1
Code: |
SET OutputLocalEnvironment.Destination.File.Directory = Directory;
SET OutputLocalEnvironment.Destination.File.Name = '*'||FileName_withtimestamp;
SET OutputLocalEnvironment.Destination.File.WildCard = '*';
SET OutputLocalEnvironment.Destination.File.Offset = Environment.Variables.NextRecordOffset; |
As mentioned in the above thread, I am reading a file as fixed length by setting appropriate properties in FileRead node. |
Yes, I can read. But it seems that you cannot. Can you please explain HOW THE FLOW READS ALL THE RECORDS ?
ok, don't bother. wasting my time |
|
Back to top |
|
 |
kash3338 |
Posted: Sat Aug 03, 2013 8:36 am Post subject: Re: File Read Node record number update |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
visasimbu wrote: |
But what filter expression is needed by broker to make the Record number as incremental ? |
The document is slightly misleading when it says filter expression. It is actually Record Selection Expression.
Quote: |
The record selection expression specifies the record to be propagated to the output terminal. The node starts at the offset specified on the request panel, and then finds each record using the settings on the record detection panel. It propagates the first record that matches the record selection expression, and then stops processing. If no record matches, the original message is sent to the "No match" terminal.
The expression can be set to any valid XPath expression that returns a Boolean value. It is possible to access the input message, the result message for the record from the file, and the possible output message. This can be used to select a particular record from the file. For example:
To take the 5th record, set the expression to
$OutputLocalEnvironment/File/Read/RecordNumber = 5
To match a key from the incoming message set the expression to
$ResultRoot/MRM/key=$InputRoot/XMLNSC/Invoice/Name
The default true() means that the first record found will be propagated.
For an example, see the Message Routing sample, which uses all the fields on the request panel. |
|
|
Back to top |
|
 |
kash3338 |
Posted: Sat Aug 03, 2013 8:38 am Post subject: Re: File Read Node record number update |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
dogorsy wrote: |
Can you please explain HOW THE FLOW READS ALL THE RECORDS ? |
When the OP says he reads all the records from a file, I guess he meant one file with multiple records in it. He is reading that file using the file read node. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Aug 06, 2013 5:29 am Post subject: Re: File Read Node record number update |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kash3338 wrote: |
dogorsy wrote: |
Can you please explain HOW THE FLOW READS ALL THE RECORDS ? |
When the OP says he reads all the records from a file, I guess he meant one file with multiple records in it. He is reading that file using the file read node. |
Which mean the OP has a flow with a loop in it, a bad practice to which I think attention was trying to be drawn. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 06, 2013 7:02 am Post subject: Re: File Read Node record number update |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Vitor wrote: |
Which mean the OP has a flow with a loop in it, a bad practice to which I think attention was trying to be drawn. |
It's not a bad practice to construct a flow with a loop in it.
There are several ways that one can construct a loop that is harmful.
It's not a bad practice to read all records from a file, either in a single go or in a loop.
It's bad practice to fail to plan for one's requirements.
But if the intent is to read only the first record in the file, then it's not clear why the FileRead node is reading more than one record from the file.
If the intent is to read and process all records in the file, individually, and do different processing on the first record than on the rest of the records, there are several very straight forward ways to do this that don't rely on being confused about the properties that the FileRead node sets.
I'd tend to use a boolean in the Environment tree, myself. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Aug 06, 2013 7:23 am Post subject: Re: File Read Node record number update |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
Vitor wrote: |
Which mean the OP has a flow with a loop in it, a bad practice to which I think attention was trying to be drawn. |
It's not a bad practice to construct a flow with a loop in it. |
I amend my statement to be "not a recommended practice because...
mqjeff wrote: |
There are several ways that one can construct a loop that is harmful. |
...and it's therefore something to be avoided if alternatives exist.
As, on the face of it & as you correctly point out, they seem to here. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 06, 2013 7:28 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It's recommended practice to construct loops in good ways.
You can't just say "don't use loops". that's like saying "Don't use integers". |
|
Back to top |
|
 |
dogorsy |
Posted: Tue Aug 06, 2013 7:34 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
mqjeff wrote: |
It's recommended practice to construct loops in good ways.
You can't just say "don't use loops". that's like saying "Don't use integers". |
or even: "use loops with integer counters, but do not increment them"  |
|
Back to top |
|
 |
|