Hi All,
I started working on webMethods developer 6.5 from past 10 days, here is my requirement … I have a flow service which gets a file converts to values and inserts the same to local database … I have scheduled the same for some interval … I want to stop the flow when particular file is not found in the directory path mentioned … please tell me how i should go ahead … I am very new to this envi and java … step by step approach if any is appreciatable …
It would be better you provide your requirement clear and upto point to get quick responses.
In the start of the service, get the list of the files in the directory. You can write a java service for that. Loop through the list and check if the mentioned file is there. Proceed to process it if it is there otherwise quit the flow.
You can use the following code for java service. Import java.IO.File, java.util.*, java.lang.String packages in the ‘shared’ section of the java service. The input is ‘filepath’ string output if fileList doc list and length (no of files)
IDataCursor pipelineCursor = pipeline.getCursor();
String filepath = IDataUtil.getString( pipelineCursor, "filepath" );
try {
String fileSep = System.getProperty("file.separator");
File f1 = new File (filepath);
if (f1.exists ()) {
String filenames1 [] = f1.list();
IData[] fileList = new IData[filenames1.length];
String type = "";
int j = 0;
for (int i = 0; i < filenames1.length; i ++) {
File f2 = new File ( filepath + fileSep + filenames1[i]);
if (f2.isDirectory ())
type = "d";
else {
if (filenames1[i].endsWith("zip"))
type="z";
else
type = "f";
}
fileList[j] = IDataFactory.create();
IDataCursor fileListCursor = fileList[j].getCursor();
IDataUtil.put( fileListCursor, "fileName", filenames1[i] );
IDataUtil.put( fileListCursor, "size", String.valueOf(f2.length()));
IDataUtil.put( fileListCursor, "type", type );
fileListCursor.destroy();
j ++;
}
IDataUtil.put( pipelineCursor, "fileList", fileList );
IDataUtil.put( pipelineCursor, "length", String.valueOf(j));
} else {
IDataUtil.put( pipelineCursor, "message", filepath + " directory does not exist");
}
} finally {
if (pipelineCursor != null)
pipelineCursor.destroy();
}
Hi…
In webMethods v6.5, File polling mechanism will give you the facility to trigger a particular service based on the creation of the file in a specific location(System Directory).So, here because of this you need not worry about the “service execution without file data”, since due to this file polling when the file exists only the service will be started.
So, i think u need not bother about the existance of the file but take care about the file data.
Good response Fani. No need for Java here (as is the case most of the time). I guess more importantly, no need to reinvent the wheel! For most integration needs, a facility of some sort already exists.