Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java BlueSpring XML中空交换的apache camel简单语言测试不起作用_Java_Null_Apache Camel - Fatal编程技术网

Java BlueSpring XML中空交换的apache camel简单语言测试不起作用

Java BlueSpring XML中空交换的apache camel简单语言测试不起作用,java,null,apache-camel,Java,Null,Apache Camel,我使用ApacheCamel 2.17并使用简单语言捕获空交换。它不起作用,我尝试了几种格式化方法,但它没有捕获空值。我相信这是我如何使用它的格式/语法。请告诉我哪里出错了。谢谢大家! <process id="_process18" ref="csvMarshallerProcessor"/> <process id="toReOrgCSV" ref="reOrgCSVData"/> <choice id="_choice13"> <when

我使用ApacheCamel 2.17并使用简单语言捕获空交换。它不起作用,我尝试了几种格式化方法,但它没有捕获空值。我相信这是我如何使用它的格式/语法。请告诉我哪里出错了。谢谢大家!

<process id="_process18" ref="csvMarshallerProcessor"/>
<process id="toReOrgCSV" ref="reOrgCSVData"/>
<choice id="_choice13">
    <when id="_when13">
        <simple>"${body}" == null</simple>
        <log id="_log22" message="body is NULL, do not send NULL body!"/>
        <stop id="_stop7"/>
    </when>
    <otherwise id="_otherwise1">

“${body}”==null
我试过了

<simple>"${body} == null"</simple>
<simple>"${body}" == null</simple>
<simple>${body} == null</simple>
<simple>${body} == 'null'</simple>
“${body}==null”
“${body}”==null
${body}==null
${body}=='null'
在上一个过程中,如果数据被过滤掉并且没有资格发送,我将交换设置为null。我只想使用Camel-Spring XML


???

不要将
交换设置为null,因为这是无效的,请将消息正文设置为null或空字符串等

exchange.getIn().setBody(null);
然后你可以用simple来测试它的空值

${body} == null
或者如果您将其设置为空文本

${body} == ''

不要将
交换设置为null,因为这是无效的,请将消息正文设置为null或空字符串等

exchange.getIn().setBody(null);
然后你可以用simple来测试它的空值

${body} == null
或者如果您将其设置为空文本

${body} == ''
谢谢你,克劳斯

这就是我的结局

...
    line.append(System.lineSeparator());

    if ( lookup ) {
        if ( validate(fleetName, line.toString()) ) {
            baos.write(line.toString().getBytes());
        }
    } else {
            baos.write(line.toString().getBytes());
    }
 }
    List<String> serviceRecords = new ArrayList<String>(Arrays.asList(baos.toString().split(System.lineSeparator())));

    if ( serviceRecords.size() > 1 ) {  //has more than a header
        byte[] ba = baos.toByteArray();
        exchange.getIn().setBody(ba);
    } else {
        exchange.getIn().setBody(null);  //empty message, only header, no data
    }

Camel Context
    <process id="_process18" ref="csvMarshallerProcessor"/>
    <choice id="_choice13">
        <when id="_when13">
            <simple trim="true">"${body}" == "" || ${body} == null</simple>
            <log id="_log22" message="body is NULL, do not send NULL body!"/>
            <stop id="_stop7"/>
        </when>
        <otherwise id="_otherwise1">
            <process id="toReOrgCSV" ref="reOrgCSVData"/>
            <to id="_to7" uri="{{DDFEndpoint}}?fileName={{APMLoaderPath}}/${header.aircraftMetadata.shipNumber}-${header.enginePosition}_${header.messageDateTime}.csv"/>
            <log id="_log23" message="Sending data packet: ${header.aircraftMetadata.outputPath}/${header.aircraftMetadata.shipNumber}-${header.enginePosition}_${header.messageDateTime}.csv"/>
        </otherwise>
    </choice>
</aggregate>
。。。
line.append(System.lineSeparator());
如果(查找){
if(验证(fleetName,line.toString())){
write(line.toString().getBytes());
}
}否则{
write(line.toString().getBytes());
}
}
List serviceRecords=new ArrayList(Arrays.asList(baos.toString().split(System.lineSeparator()));
如果(serviceRecords.size()>1){//有多个头
字节[]ba=baos.toByteArray();
exchange.getIn().setBody(ba);
}否则{
exchange.getIn().setBody(null);//消息为空,只有头,没有数据
}
骆驼上下文
“${body}”==”| |${body}==null
谢谢你,克劳斯

这就是我的结局

...
    line.append(System.lineSeparator());

    if ( lookup ) {
        if ( validate(fleetName, line.toString()) ) {
            baos.write(line.toString().getBytes());
        }
    } else {
            baos.write(line.toString().getBytes());
    }
 }
    List<String> serviceRecords = new ArrayList<String>(Arrays.asList(baos.toString().split(System.lineSeparator())));

    if ( serviceRecords.size() > 1 ) {  //has more than a header
        byte[] ba = baos.toByteArray();
        exchange.getIn().setBody(ba);
    } else {
        exchange.getIn().setBody(null);  //empty message, only header, no data
    }

Camel Context
    <process id="_process18" ref="csvMarshallerProcessor"/>
    <choice id="_choice13">
        <when id="_when13">
            <simple trim="true">"${body}" == "" || ${body} == null</simple>
            <log id="_log22" message="body is NULL, do not send NULL body!"/>
            <stop id="_stop7"/>
        </when>
        <otherwise id="_otherwise1">
            <process id="toReOrgCSV" ref="reOrgCSVData"/>
            <to id="_to7" uri="{{DDFEndpoint}}?fileName={{APMLoaderPath}}/${header.aircraftMetadata.shipNumber}-${header.enginePosition}_${header.messageDateTime}.csv"/>
            <log id="_log23" message="Sending data packet: ${header.aircraftMetadata.outputPath}/${header.aircraftMetadata.shipNumber}-${header.enginePosition}_${header.messageDateTime}.csv"/>
        </otherwise>
    </choice>
</aggregate>
。。。
line.append(System.lineSeparator());
如果(查找){
if(验证(fleetName,line.toString())){
write(line.toString().getBytes());
}
}否则{
write(line.toString().getBytes());
}
}
List serviceRecords=new ArrayList(Arrays.asList(baos.toString().split(System.lineSeparator()));
如果(serviceRecords.size()>1){//有多个头
字节[]ba=baos.toByteArray();
exchange.getIn().setBody(ba);
}否则{
exchange.getIn().setBody(null);//消息为空,只有头,没有数据
}
骆驼上下文
“${body}”==”| |${body}==null