<route autoStartup="true">
<from uri="mqtt:groupData?host=tcp://127.0.0.1:1883&userName={{mq_user}}&password={{mq_pwd}}&subscribeTopicNames=ds/+/data"/>
<bean ref="advServiceBean" method="groupDataOs"/>
<!--过滤掉返回信息为null的值-->
<filter>
<simple>${body} == null</simple>
<stop/>
</filter>
<setHeader headerName="topicName">
<jsonpath>$.topicName</jsonpath>
</setHeader>
<!-- <log message="${header.id}"/>-->
<multicast>
<toD uri="activemq:topic:${header.topicName}?username={{mq_user}}&password={{mq_pwd}}"/>
</multicast>
</route>
filter标签就是过滤掉的null结果的,其他的只是业务逻辑的代码配置
当然,还有一种方式,差不多,也顺便记一下
<route>
<from uri="direct:routePublishedResponse"/>
<bean ref="caseHearingHandler"/>
<choice>
<when>
<simple>${body} != null</simple>
<to uri="direct:resultSubRoute">
</when>
<otherwise>
<log message="skipping due to NULL body" loggingLevel="DEBUG" />
</otherwise>
</choice>
</route>