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 » Reading several files from directory using File Read Node ?

Post new topic  Reply to topic
 Reading several files from directory using File Read Node ? « View previous topic :: View next topic » 
Author Message
Johan448
PostPosted: Wed Sep 25, 2013 11:30 pm    Post subject: Reading several files from directory using File Read Node ? Reply with quote

Newbie

Joined: 27 May 2013
Posts: 5

Hello!

I am trying to get the file read node to read several xml files (5 to be exact) from one directory and the put them on a queue.

My setup right now is MQInput -> FileRead -> MQOutput....I send a trigger message to the input, then i want the file read to read the 5 files from a directory and put them on the outputq.

The name of my files are
-Customer1.xml
-Customer2.xml
-Customer3.xml
-Customer4.xml
-Customer5.xml

I tried specifying *.xml in File name of Pattern property but i get an exception...

This is take from the infocenter
"A file name, or a character sequence (pattern) that matches a file name. A pattern contains at least one of the following wildcard characters:

Asterisk (*), representing any sequence of zero or more characters
Question mark (?), representing any single character

If more than one file matches the pattern, an exception is thrown.
"

Any ideas on how i can make it read all of the 5 files...or maybe a different solution?

Thanks in advance!
Back to top
View user's profile Send private message
dogorsy
PostPosted: Thu Sep 26, 2013 1:21 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

maybe setting the substituteWildcardMatch property in the fileRead node, then add a compute node before the file read and set the LocalEnvironment.Wildcard.WildcardMatch to Customer1.xml, etc.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Sep 26, 2013 5:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

It sounds like you are trying to hack together your own Collection pattern or Aggregation pattern.
Back to top
View user's profile Send private message
cognizant
PostPosted: Thu Sep 26, 2013 9:18 pm    Post subject: Reply with quote

Newbie

Joined: 26 Sep 2013
Posts: 2

Use the compute node before the Read file node and write the below Esql code.

CREATE COMPUTE MODULE FIleInput_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE I INTEGER 0;
SET Environment.FileFound = true;
-- Read as long as there are files / trigger after 20 files -> no endless loop on misconfiguration/error
WHILE Environment.FileFound AND I < 20 DO
-- Go to read the file
CALL CopyEntireMessage();
PROPAGATE TO TERMINAL 'out';
SET I = I + 1;
END WHILE;
END;
Back to top
View user's profile Send private message
dogorsy
PostPosted: Thu Sep 26, 2013 9:25 pm    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

cognizant wrote:
Use the compute node before the Read file node and write the below Esql code.

CREATE COMPUTE MODULE FIleInput_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE I INTEGER 0;
SET Environment.FileFound = true;
-- Read as long as there are files / trigger after 20 files -> no endless loop on misconfiguration/error
WHILE Environment.FileFound AND I < 20 DO
-- Go to read the file
CALL CopyEntireMessage();
PROPAGATE TO TERMINAL 'out';
SET I = I + 1;
END WHILE;
END;

@cognizant:
1- please edit your post and add code tags where corresponds.
2- the code you posted is irrelevant to the OP description of the problem. All you are doing is propagating 20 messages, which means the OP will get 20 error messages, as at the moment he cannot read a single file.
Back to top
View user's profile Send private message
Esa
PostPosted: Fri Sep 27, 2013 1:12 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Maybe something like this:

Code:
CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
      CREATE LASTCHILD OF InputLocalEnvironment TYPE Name NAME 'Filenames';
      DECLARE fRef REFERENCE TO InputLocalEnvironment.Filenames;
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer1.xml';
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer2.xml';
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer3.xml';
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer4.xml';
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer5.xml';
      
      FOR filenameRef AS fRef.Filename DO
         SET OutputLocalEnvironment.Destination.File.Name = FIELDVALUE(filenameRef);
         PROPAGATE TO TERMINAL 0 ENVIRONMENT OutputLocalEnvironment MESSAGE InputRoot;
      END FOR;
      
      RETURN TRUE;
   END;
END MODULE;
Back to top
View user's profile Send private message
dogorsy
PostPosted: Fri Sep 27, 2013 2:23 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

Esa wrote:
Maybe something like this:

Code:
CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
      CREATE LASTCHILD OF InputLocalEnvironment TYPE Name NAME 'Filenames';
      DECLARE fRef REFERENCE TO InputLocalEnvironment.Filenames;
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer1.xml';
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer2.xml';
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer3.xml';
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer4.xml';
      CREATE LASTCHILD OF fRef TYPE NameValue NAME 'FileName' VALUE 'Customer5.xml';
      
      FOR filenameRef AS fRef.Filename DO
         SET OutputLocalEnvironment.Destination.File.Name = FIELDVALUE(filenameRef);
         PROPAGATE TO TERMINAL 0 ENVIRONMENT OutputLocalEnvironment MESSAGE InputRoot;
      END FOR;
      
      RETURN TRUE;
   END;
END MODULE;


Only if the OP wants read the whole file in the fileRead node. Otherwise more logic is required. I would leave it to the OP to decide what he wants to do and write the relevant code. He already had a few suggestions and has not given any feedback.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Reading several files from directory using File Read 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.