Routes 使用zipAggregationStrategy时如何在压缩文件中保留原始文件名
我的路线结构如下: B2BMB文件中的文件ystem://com.abc/sftp/abc/Aggregated001 按顺序命名为:123.dat、456.dat、789.dat。在压缩文件中,这些文件名被重命名为机器ID。我们是否可以保留文件名Routes 使用zipAggregationStrategy时如何在压缩文件中保留原始文件名,routes,apache-camel,Routes,Apache Camel,我的路线结构如下: B2BMB文件中的文件ystem://com.abc/sftp/abc/Aggregated001 按顺序命名为:123.dat、456.dat、789.dat。在压缩文件中,这些文件名被重命名为机器ID。我们是否可以保留文件名 <routes xmlns="http://camel.apache.org/schema/spring"> <route id="com.abc.zipFile001" autoStartup="false"> &l
<routes xmlns="http://camel.apache.org/schema/spring">
<route id="com.abc.zipFile001" autoStartup="false">
<from uri="b2bmbFileSystem://com.abc/sftp/abc/Aggregated001"/>
<convertBodyTo type="java.lang.String"/>
<choice id="textZipFile">
<when>
<simple>$simple{header.CamelFileName} regex '^.*(dat|DAT)$'</simple>
<aggregate strategyRef="zipAggregationStrategy" completionFromBatchConsumer="true" eagerCheckCompletion="true">
<correlationExpression>
<constant>true</constant>
</correlationExpression>
<setHeader headerName="CamelFileName">
<simple>${date:now:yyyy-MM-dd-HH-mm-ssSSS}-ZIPFILES.zip</simple>
</setHeader>
<to uri="b2bmbFileSystem://com.abc/sftp/abc/shipmentRequestAggregatedPGH"/>
</aggregate>
</when>
</choice>
</route>
</routes>
请参阅ZipAggregationStrategy构造函数选项useFilenameHeader
发件人:
useFilenameHeader-如果为true,则文件名头将用于命名ZIP文件中的聚合字节数组
在SpringXML配置中,您可以通过以下方式定义ZipaggregationStrategybean:
<bean id="zipAggregationStrategy" class="org.apache.camel.processor.aggregate.zipfile.ZipAggregationStrategy">
<constructor-arg index="0" value="false"/> <!-- preserveFolderStructure -->
<constructor-arg index="1" value="true"/> <!-- useFilenameHeader -->
</bean>