【发布时间】:2018-03-21 23:37:40
【问题描述】:
我是否尝试在换行符上拆分消息并使用以下脚本:
def mesType = "";
def lines = message.getPayload().split("\n");
if ( lines[0][0..6] == '123456' || lines[1][0..6] == '123456') {
mesType = "MES1";
}
if ( lines[0][0..7] == '654321' || lines[1][0..7] == '654321') {
mesType = "MES2";
}
if ( lines[0][0..7] == '234561' || lines[1][0..7] == '234561') {
mesType = "MES3";
}
message.setProperty('mesType', mesType);
return message.getPayload();
但是当我使用它时,我的日志文件中出现以下错误:
groovy.lang.MissingMethodException: No signature of method: [B.split() is applicable for argument types: (java.lang.String) values: {"\n"} (javax.script.ScriptException)
当我将分割线更改为以下内容时:
def lines = message.getPayload().toString().split("\n");
我收到一个错误,指出数组已超出界限,因此看起来它仍然没有对换行符执行任何操作。
传入的消息 (message.getPayload) 是来自文件系统的消息,并且包含换行符。它看起来像这样:
ABCDFERGDSFF
123456SDFDSFDSFDSF
JGHJGHFHFH
我做错了什么?使用 Mule 2.X 收集消息
【问题讨论】: