骡子选择路线取决于有效载荷类型,即对象类型?

Mule choice route depending on payload type ie object type?

我可以根据负载选择路线。有效负载可以是列表、映射或字符串。必须根据有效负载类型识别和路由有效负载。

我想你想要这样的东西

<choice doc:name="Choice">
        <when expression="#[payload is List]">
            <logger level="INFO" message="i am list" doc:name="Logger"/>
        </when>
        <when expression="#[payload is Map]">
            <logger level="INFO" message="i am map" doc:name="Logger"/>
        </when>
        <when expression="#[payload is String]">
            <logger level="INFO" message="i am string" doc:name="Logger"/>
        </when>
        <otherwise> 
            <logger message="class doesnt match with [list, map, string]" level="INFO" doc:name="Logger"/>  
        </otherwise>  
    </choice>

我同意 Eddú 的回应,除了我会添加一个 otherwise 路径。如果你不这样做并得到不同于列表映射或字符串的东西,你会得到相当神秘的错误:

org.mule.api.routing.RoutePathNotFoundException: Can't process message because no route has been found matching any filter and no default route is defined. Failed to route event via endpoint: ChoiceRouter [flow-construct=testNull, started=true]. Message payload is of type: NullPayload