Am I trying to split a message on a newline character and use the following script:
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();
But when I use this I got the following error in my log file:
groovy.lang.MissingMethodException: No signature of method: [B.split() is applicable for argument types: (java.lang.String) values: {"\n"} (javax.script.ScriptException)
When I changes the split line to the following:
def lines = message.getPayload().toString().split("\n");
I get an error that the array is OutOfBound, so it looks like it is still not doing anything on the newline character.
The message that comes in (message.getPayload
) is a message from the file system, and does contain newline characters. It looks like this:
ABCDFERGDSFF
123456SDFDSFDSFDSF
JGHJGHFHFH
What am I doing wrong? Message is collected using Mule 2.X