4 Replies Latest reply on Jun 23, 2008 3:07 PM by Scott Ryan

    Need to handle directory recursion on the FileGatewayListene

    Scott Ryan Newbie

      I have a need to implement directory recursion on the FileGatewayListner. For Example I would like to have a hierarchical structure to my directories and have the file reader pick up all files in all directories and place them into a JMS queue. Then I can process them based on the full file path. This keeps me from having to define an individual directory location for each one and makes the system more dynamic. Most of the other ESB's I have checked provide a flag for this capability but I was not able to find one in the JBoss ESB.

      1. Is this capability available today in the FileGatewayListener?
      2. I extended the current FileGatewayListener to provide this capability but cannot figure out how to get the ESB to use my class rather than the JBoss supplied one? Is there a file that matches the jboss-esb.xml parameters with their corresponding class files like other ESB implementations?

      For Example how do i get the FileGatewayListener defined below to use my class rather than the default from JBoss?

      <?xml version = "1.0" encoding = "UTF-8"?>
       <fs-provider name="FSproviderOpens">
       <fs-bus busid="TrackingFileChannel">
       <fs-message-filter directory="${TRACKING_INPUT_DIRECTORY}" input-suffix=".done"
       work-suffix=".esbWorking" post-delete="false"
       post-directory="${TRACKING_OUTPUT_DIRECTORY}" post-suffix=".sentToEsb"
       error-delete="false" error-directory="${TRACKING_ERROR_DIRECTORY}"
       error-suffix=".IN_ERROR" />
       <jms-provider name="JBossMessaging" connection-factory="ConnectionFactory">
       <jms-bus busid="TrackingEsbChannel">
       <jms-message-filter dest-type="QUEUE" dest-name="queue/EDS_TRACKING_QUEUE"
       selector="type='fromTrackingFileAction'" />
       <service category="trackingCategory" name="trackingFileListener"
       description="Tracking File Action (esb listener)">
       <fs-listener name="FileGateway" busidref="TrackingFileChannel" maxThreads="1"
       is-gateway="true" schedule-frequency="10" />
       <jms-listener name="TrackingFileAction" busidref="TrackingEsbChannel" maxThreads="1" />
       <actions mep="OneWay">
       <action name="detailAction"
       process="processMessage" />
       <action name="dump" class="org.jboss.soa.esb.actions.SystemPrintln">
       <property name="printfull" value="true" />

        • 1. Re: Need to handle directory recursion on the FileGatewayLis
          Tom Fennelly Master

          In the current architecture, the only way to plug in your own listener is to use the base provider and listener config types (defined in the XSD).

          If I were you I'd look at adding a custom ScheduledEventMessageComposer for doing this. Extending the existing FileGateway etc is just too hard IMO.

          There's an example of how you might do this in SVN (not in the main codebase). You could take it (no warranty/support etc) and add the recursion to it. It's at http://anonsvn.labs.jboss.com/labs/jbossesb/workspace/sandbox/jbossesb-ext. Read the README.txt ... build the Javadoc and have a look at the javadoc for the FileListener class.

          Note again... this is provided as is... no warranty etc!

          • 2. Re: Need to handle directory recursion on the FileGatewayLis
            Tom Fennelly Master

            Just to add... I think you might even be able to take that as is, implement your own FileSelector that recurses down the file tree and just plug it into the FileListener using the "fileSelector" property.

            Best of luck.

            • 3. Re: Need to handle directory recursion on the FileGatewayLis
              Scott Ryan Newbie

              I was able to download the code and build my own File Selector. The problem is that it looks like the file reader is broken. Either when it reads the file or renames it the file is getting corrupted. The file contains a String and it looks like it is writing the object address of the message object to the file and removing the original contents of the file. I had assumed that the rename process would not alter the file in any way so we have the original file with a new name. The files are found in the recursive lookup and processed but the files are corrupted when they are renamed and unlike the file gateway it is not possible to move them to a new directory so the processing directory fills up.

              I will continue to work to debug this but it seems like an easy extension to add to the existing file gateway.

              • 4. Re: Need to handle directory recursion on the FileGatewayLis
                Scott Ryan Newbie

                Also given I am using a file listener now how do i get the listener to publish to a JMS queue like the file gateway rather than directly to my message processing method. There is way too much data coming into the system to not persist it to a JMS queue first for processing.