ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » File Size Calculation in Java Compute Node

Post new topic  Reply to topic Goto page 1, 2  Next
 File Size Calculation in Java Compute Node « View previous topic :: View next topic » 
Author Message
DP1234
PostPosted: Mon Jun 02, 2014 11:17 am    Post subject: File Size Calculation in Java Compute Node Reply with quote

Apprentice

Joined: 25 May 2014
Posts: 40

Hi.,
I have to calculate the file size in Java Compute Node.,How can i do this
My flow has FileInput Node>> Java Compute Node>>File output Node

Please Help me out
Thanks
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jun 02, 2014 11:37 am    Post subject: Re: File Size Calculation in Java Compute Node Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

DP1234 wrote:
I have to calculate the file size in Java Compute Node


Why? What value does this information have? What use can you put it to?

Certainly you don't need to know it to process the file's contents. So if you explain why you think you need it, we can suggest alternative.

Better information, better advice.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
DP1234
PostPosted: Mon Jun 02, 2014 9:37 pm    Post subject: Re: File Size Calculation in Java Compute Node Reply with quote

Apprentice

Joined: 25 May 2014
Posts: 40

Vitor wrote:
DP1234 wrote:
I have to calculate the file size in Java Compute Node


Why? What value does this information have? What use can you put it to?

Certainly you don't need to know it to process the file's contents. So if you explain why you think you need it, we can suggest alternative.

Better information, better advice.


Basically i need to cross check the actual file size with the file size value mentioned in the header of my XML input file..to analyse the integrity of file.,
In java file size can checked by
File file =new File("c:\\xyz.txt");
double bytes = file.length();

But once file input node fetches my input file it no more occurs in directory so i cant use above logic...Please do suggest is there any alternate solution to calculate file size in JCN upon getting from File input node
Back to top
View user's profile Send private message
Tibor
PostPosted: Tue Jun 03, 2014 1:10 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

If your message parser was BLOB you could easily get the file length because it is as same as the structure length.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jun 03, 2014 4:44 am    Post subject: Re: File Size Calculation in Java Compute Node Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

DP1234 wrote:
Basically i need to cross check the actual file size with the file size value mentioned in the header of my XML input file..to analyse the integrity of file.


So you're getting an XML input file, which contains the name of an actual file which you're then reading? Why not just read the file directly?

But then:
DP1234 wrote:
But once file input node fetches my input file it no more occurs in directory so i cant use above logic


If you're using the FileInput node to read a file where does this XML file fit in? If you're trying to analyse the integrity of the input XML file then file size is not an accurate method; an XML file can be a variety of different sizes (depending on the amount of whitespace) and still have integrity.

Validate XML with a schema; WMB will do this for you.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
paustin_ours
PostPosted: Tue Jun 03, 2014 5:20 am    Post subject: Reply with quote

Yatiri

Joined: 19 May 2004
Posts: 667
Location: columbus,oh

I agree with Vitor this is not the way to check the integrity of the file. If the file is coming from remote machine secure the way you put the file on your machine. length check doesn't guarantee the file is not tampered with.
Back to top
View user's profile Send private message Yahoo Messenger
zpat
PostPosted: Tue Jun 03, 2014 5:28 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

If the XML was truncated then it would fail validation?
_________________
Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error.
Back to top
View user's profile Send private message
Tibor
PostPosted: Tue Jun 03, 2014 5:35 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

Perhaps this is a double-check on their side...
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jun 03, 2014 5:51 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

zpat wrote:
If the XML was truncated then it would fail validation?


Yes - the closing root tag would be missing even if the truncation occured in whitespace between 2 child tags, rendering the document misformed.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jun 03, 2014 5:52 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Tibor wrote:
Perhaps this is a double-check on their side...


This sounds like a "double check" that has you logging message ids or consuming COD/COA messages "just in case WMQ loses a message".

Valid check, wrong method.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
DP1234
PostPosted: Tue Jun 03, 2014 11:26 am    Post subject: Re: File Size Calculation in Java Compute Node Reply with quote

Apprentice

Joined: 25 May 2014
Posts: 40

Vitor wrote:
DP1234 wrote:
Basically i need to cross check the actual file size with the file size value mentioned in the header of my XML input file..to analyse the integrity of file.


So you're getting an XML input file, which contains the name of an actual file which you're then reading? Why not just read the file directly?

But then:
DP1234 wrote:
But once file input node fetches my input file it no more occurs in directory so i cant use above logic


If you're using the FileInput node to read a file where does this XML file fit in? If you're trying to analyse the integrity of the input XML file then file size is not an accurate method; an XML file can be a variety of different sizes (depending on the amount of whitespace) and still have integrity.

Validate XML with a schema; WMB will do this for you.


No,Am reading the actual file only..,the XML file itself is the actual file whose size has to calculated and then cross checked with the size value in header..

I did placing the duplicate copy of XML input file in an directory an then apply

File file =new File("c:\\xyz.txt");
double bytes = file.length();
Logic

It works fine..,But i want size to be calculated in JCN directly..,Validation using XML schema is done..,This is also one of the requirement.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 03, 2014 11:41 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Ok.

Once you read it from FileInput, it's *not* a file any more. It's a message tree.

If you are pathologically sure that you need to confirm that the count of the bytes in the file is the same as the number put into an element in the file, then read the file as BLOB. Then get the LENGTH of the blob. Then parse the BLOB into XML.

But this is a terrible checksum notion, there are a thousand ways the file could be bad that still pass this test.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jun 03, 2014 12:30 pm    Post subject: Re: File Size Calculation in Java Compute Node Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

DP1234 wrote:
No,Am reading the actual file only..,the XML file itself is the actual file whose size has to calculated and then cross checked with the size value in header..


This is ridiculous. Utterly. As I indicated above, the file could be any number of sizes.

DP1234 wrote:
Validation using XML schema is done..,This is also one of the requirement.


One of what requirements? What is the technical reason for this additional validation? What action is your flow expected to take if the XML document passes the schema validation but has a different size (and it could)? More importantly, what is the expected action if the file size matches but the schema validation fails (and that's even more likely!)???

What value does this size check give that the schema validation does not? What exactly are you checking for? What failure scenario is this check intended to catch?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jun 03, 2014 12:44 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mqjeff wrote:
If you are pathologically sure that you need to confirm that the count of the bytes in the file is the same as the number put into an element in the file, then read the file as BLOB. Then get the LENGTH of the blob. Then parse the BLOB into XML.


That's just contact admin.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 03, 2014 12:47 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
mqjeff wrote:
If you are pathologically sure that you need to confirm that the count of the bytes in the file is the same as the number put into an element in the file, then read the file as BLOB. Then get the LENGTH of the blob. Then parse the BLOB into XML.


That's just contact admin.


The whole notion is mucked up.

But this is the closest thing that could possibly match
Quote:
the file size value mentioned in the header of my XML input file


I mean, assuming for example that the file hasn't been moved over FTP using ASCII mode.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » File Size Calculation in Java Compute Node
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.