[英]Upgrading Mule from CE-3.5 to 3.7.0 breaks file encoding
流:
<sftp:inbound-endpoint
connector-ref="sftpServer"
host="${sftp.host}"
port="${sftp.port}"
path="${sftp.path}"
user="${sftp.user}"
password="${sftp.password}"
responseTimeout="${standard.response.timeout.millis}"
sizeCheckWaitTime="${sftp.sizeCheckWaitTime.millis}"
pollingFrequency="${sftp.polling.frequency.millis}"
autoDelete="false"
encoding="UTF-16LE"
doc:name="SFTPEndpoint">
<file:filename-wildcard-filter pattern="${sftp.filename}" />
</sftp:inbound-endpoint>
<file:file-to-byte-array-transformer encoding="UTF-16LE" doc:name="Object to Byte Array" />
<byte-array-to-string-transformer encoding="UTF-8" doc:name="Byte Array to String"/>
僅更改版本號,我就開始遇到此異常:
Message : Cannot apply transformer FileToByteArray{this=74dda694, name='FileToByteArray', ignoreBadInput=false, returnClass=SimpleDataType{type=[B, mimeType='*/*', encoding='UTF-16LE'}, sourceTypes=[SimpleDataType{type=java.io.File, mimeType='*/*', encoding='null'}, SimpleDataType{type=java.io.FileInputStream, mimeType='*/*', encoding='null'}]} on source payload: class org.mule.transport.sftp.SftpInputStream (java.lang.IllegalArgumentException). Message payload is of type: SftpInputStream
Code : MULE_ERROR--2
所以我不得不改變這個:
<object-to-byte-array-transformer encoding="UTF-16LE" doc:name="Object to Byte Array" />
<byte-array-to-string-transformer encoding="UTF-8" doc:name="Object to Byte Array" />
其他所有設置都完全相同,但是現在我有了(3.7.0):
T h i s i s a t e s t f i l e .
而不是這個(使用3.5.0):
This is a test file.
在已移動文件的最終版本中。 這些不是空格字符,而是不可見的字符(我想是因為UTF16是雙字節字符集)
有什么想法嗎? 建議?
我最終創建了一個自定義的Groovy腳本來進行轉換,並將其放在入站端點之后。
<sftp:inbound-endpoint
connector-ref="sftpServer"
host="${sftp.host}"
port="${sftp.port}"
path="${sftp.path}"
user="${sftp.user}"
password="${sftp.password}"
responseTimeout="${standard.response.timeout.millis}"
sizeCheckWaitTime="${sftp.sizeCheckWaitTime.millis}"
pollingFrequency="${sftp.polling.frequency.millis}"
autoDelete="false"
encoding="UTF-16LE"
doc:name="SFTPEndpoint">
<file:filename-wildcard-filter pattern="${sftp.filename}" />
</sftp:inbound-endpoint>
<scripting:transformer doc:name="Convert File Encoding">
<scripting:script engine="Groovy" file="encodingConverter.groovy" />
</scripting:transformer>
<!-- Do flow stuff here -->
groovy腳本接收InputStream並輸出轉換后的File。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.