<beans xmlns="http://www.springframework.org/schema/beans" xmlns:ftp="http://servicemix.apache.org/ftp/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://servicemix.apache.org/ftp/1.0 http://servicemix.apache.org/schema/ftp/1.0/servicemix-ftp.xsd"> <ftp:connection id="myFtpConnection" server="ftp.example.com" port="21" username="username" password="password" /> <ftp:listener-container id="container" connection="myFtpConnection" auto-startup="true"> <ftp:listener endpoint="myEndpoint" directory="/path/to/folder" /> </ftp:listener-container> <import resource="classpath:com/example/myFtpProcessor.xml" /> </beans> public class MyFtpProcessor implements Processor { public void process(Exchange exchange) throws Exception { org.apache.camel.component.file.GenericFile<?> file = (org.apache.camel.component.file.GenericFile<?>) exchange.getIn().getBody(); byte[] content = exchange.getContext() .getTypeConverter() .convertTo(byte[].class, file.getBody()); // ... FileUtils.forceDelete(file.getFile()); } } <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> <bean id="myFtpProcessor" class="com.example.MyFtpProcessor" /> <camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/blueprint" trace="false" handleFault="false"> <route id="ftpRoute"> <from uri="ftp:myEndpoint" /> <process ref="myFtpProcessor"/> </route> </camelContext> </blueprint>


上一篇:
下一篇:
切换中文