IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Restrict the flow when file doesn't exists

    Posted Tue April 01, 2008 09:37 AM

    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 …

    Thanks in adv
    Sra1


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: Restrict the flow when file doesn't exists

    Posted Tue April 01, 2008 10:29 AM

    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.

    Cheers
    Guna


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Restrict the flow when file doesn't exists

    Posted Tue April 01, 2008 11:26 AM

    Hi Guna,

    Thanks for the your response … can you pls gimme more details in creating a java service … I am not sure about java …

    Thanks in Advance
    Sravan


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 4.  RE: Restrict the flow when file doesn't exists

    Posted Tue April 01, 2008 11:47 AM

    Hi,

    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();
    }

    Cheers
    Guna


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 5.  RE: Restrict the flow when file doesn't exists

    Posted Tue April 01, 2008 01:22 PM

    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.

    Thanks
    Fani


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 6.  RE: Restrict the flow when file doesn't exists

    Posted Tue April 01, 2008 04:46 PM

    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.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 7.  RE: Restrict the flow when file doesn't exists

    Posted Tue April 01, 2008 05:54 PM

    If you still intend to use the above java code
    Small correction
    In the import:java.io.File not Java.IO.File.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services