6 Replies Latest reply on Jul 24, 2013 4:22 PM by mp_valle77

    Original file name as message property for File/FTP gateways

    derek.adams

      I have some code that adds the originating filename as a property on messages coming from file or FTP gateways. In our business case, we needed to be able to take the original filename, modify it with a timestamp and use that as the filename on an outgoing FTP. Our solution was an action that executes a chain of strategies on the incoming filename, passing the end result to a NotifyFTP action. The config looks like this...

      <jbossesb parameterReloadSecs="5" xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
       <providers>
       <jms-provider name="JBossMQ" connection-factory="ConnectionFactory" jndi-URL="localhost">
       <jms-bus busid="MyESBChannel">
       <jms-message-filter dest-name="queue/A" dest-type="QUEUE"/>
       </jms-bus>
       </jms-provider>
       <fs-provider name="MyFileProvider">
       <fs-bus busid="MyFileBus">
       <fs-message-filter directory="/temp" input-suffix=".esbdat" work-suffix=".esbInProcess" post-delete="true"
       post-directory="processed" post-suffix=".esbDone" error-delete="true" error-directory="processed" error-suffix=".esbERROR"/>
       </fs-bus>
       </fs-provider>
       <ftp-provider name="MyFtpProvider" hostname="localhost">
       <ftp-bus busid="MyFtpBus">
       <ftp-message-filter directory="/" username="anonymous" password="none" input-suffix=".esbdat" work-suffix=".esbInProcess"
       post-delete="true" post-directory="processed" post-suffix=".esbDone" error-delete="true" error-directory="processed"
       error-suffix=".esbERROR" passive="false" protocol="ftp"/>
       </ftp-bus>
       </ftp-provider>
       </providers>
       <services>
       <service category="FirstServiceESB" name="SimpleListener" description="Hello World">
       <listeners>
       <fs-listener name="InFromFile" busidref="MyFileBus" maxThreads="1" is-gateway="true" poll-frequency-seconds="3"/>
       <ftp-listener name="InFromFTP" busidref="MyFtpBus" maxThreads="1" is-gateway="true" poll-frequency-seconds="8"/>
       <jms-listener name="EsbListener" busidref="MyESBChannel" maxThreads="1" is-gateway="false"/>
       </listeners>
       <actions>
       <action name="BuildFilename" class="org.jboss.soa.esb.actions.naming.FileNameGeneratorAction">
       <property name="strategies" value="">
       <strategies>
       <strategy class="org.jboss.soa.esb.actions.naming.strategy.ChangeSuffixNamingStrategy" newSuffix="proc"/>
       <strategy class="org.jboss.soa.esb.actions.naming.strategy.AddTimestampNamingStrategy"/>
       </strategies>
       </property>
       </action>
       <action name="SendToFTP" class="org.jboss.soa.esb.actions.Notifier">
       <property name="okMethod" value="notifyOK"/>
       <property name="notification-details" value="">
       <NotificationList type="OK">
       <target class="NotifyFTP">
       <ftp URL="ftp://user:password@server.com/home/user" filename="{org.jboss.soa.esb.naming.result}"/>
       </target>
       </NotificationList>
       </property>
       </action>
       </actions>
       </service>
       </services>
      </jbossesb>


      The FileNameGeneratorAction uses the message property for originating filename set in the gateway by default (can be changed via action props) and writes the result to a well-known message prop name. The NotifyFTP action picks up the result value and uses that as the filename it writes.

      I figure that this may be helpful to other people with similar requirements, so I was wondering if I should check the code in. Alternatively, I can add a JIRA and attach the updates so people can take a look before it goes in the trunk.

      Thanks,
      Derek