Some issues about use FTP action
sdjn5337 Aug 18, 2008 3:11 AMHello, I want to run the example 'helloworld_ftp_action' today. But I got some questions
I started a ftp server 192.168.1.1 with username sa and password sa.
after deploy the .esb archive, the jboss-esb.xml as follows
<providers> <ftp-provider name="FTPprovider" hostname="192.168.1.1" > <ftp-bus busid="helloFTPChannel" > <ftp-message-filter username="sa" password="sa" passive="false" directory="jbossesb" input-suffix=".dat" work-suffix=".esbWorking" post-delete="false" post-suffix=".COMPLETE" error-delete="false" error-suffix=".HAS_ERROR" /> </ftp-bus> </ftp-provider> <jms-provider name="JBossMQ" connection-factory="ConnectionFactory" jndi-context-factory="org.jnp.interfaces.NamingContextFactory" jndi-URL="localhost" > <jms-bus busid="quickstartEsbChannel"> <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_helloworld_ftp_esb" selector="source='fromHelloworldFTPAction'" /> </jms-bus> </jms-provider> <schedule-provider name="cronExample"> <cron-schedule scheduleid="cron-schedule" cronExpression="0/5 * * * * ?"/> </schedule-provider> </providers> <services> <service category="myCategory" name="myFileListener" description="Hello World File Action (esb listener)" > <listeners> <ftp-listener name="FtpGateway" busidref="helloFTPChannel" maxThreads="1" is-gateway="true" scheduleidref="cron-schedule"/> <jms-listener name="helloWorldFileAction" busidref="quickstartEsbChannel" maxThreads="1" /> </listeners> <actions> <action name="action1" class="org.jboss.soa.esb.samples.quickstart.helloworldftpaction.MyAction" process="displayMessage,playWithMessage" /> </actions> </service> </services> </jbossesb>
In FTP server I can see that the sa has connect to it.
After I call the target 'ant runtest', it only create a file on FTP server but didn't invoke any method in JbossESB.
Here is the test class
package org.jboss.soa.esb.samples.quickstart.helloworldftpaction.test; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; public class CreateTestFile { public static void main(final String[] args) { if (args.length != 5) { System.err.println("Usage: java " + CreateTestFile.class.getName() + " <hostname> <username> <password> <filename> <contents>") ; System.exit(1) ; } else { final String hostname = args[0] ; final String username = args[1] ; final String password = args[2] ; final String filename = args[3] ; final String contents = args[4] ; final URL url ; final String filenameVal ; if (filename.charAt(0) == '/') { filenameVal = (filename.length() > 1 ? "%2F" + filename.substring(1) : "%2F") ; } else { filenameVal = filename ; } try { url = new URL("ftp://" + username + ":" + password + "@" + hostname + "/" + filenameVal) ; } catch (final MalformedURLException murle) { exit("Invalid URL: " + filenameVal, murle, 2) ; return ; // for compiler } final URLConnection connection ; try { connection = url.openConnection() ; } catch (final IOException ioe) { exit("Error accessing location: " + filenameVal, ioe, 3) ; return ; // for compiler } connection.setDoOutput(true) ; final OutputStream os ; try { os = connection.getOutputStream() ; } catch (final IOException ioe) { exit("Error obtaining output stream for location: " + filenameVal, ioe, 4) ; return ; // for compiler } try { final PrintStream ps = new PrintStream(os) ; ps.print(contents) ; ps.close() ; } finally { try { os.close() ; } catch (final IOException ioe) {} //ignore } } } private static void exit(final String message, final Throwable th, final int exitValue) { System.err.println(message) ; th.printStackTrace() ; System.exit(exitValue) ; } }
First I want to know what does this mean in jboss-esb.xml?
<schedule-provider name="cronExample"> <cron-schedule scheduleid="cron-schedule" cronExpression="0/5 * * * * ?"/> </schedule-provider>
Second, in the test class, does the value of hostname, username, password is the FTP's or others? (If FTP's only put the file to FTP not via ESB)
Third, If I want to put the file 'upload.txt' to the FTP and download the file 'download.xml' from the ftp server via JbossESB. How should I do?
T.