Reputation: 81
I have a Mule sub flow with a possibly two outbound JMS queues. When I use MEL to make a choice based on header values, my messages end up in one queue as if MEL is not even executed:
<sub-flow name="enqueueFlow">
<!--logger message="Message inbound #[message.inboundProperties['myheader']]" doc:name="Test Flow logging" level="INFO"/-->
<choice doc:name="QueueChoice">
<when expression="#[message.inboundProperties['myheader'] != null and message.inboundProperties['myheader'] == 'urgent']">
<set-variable variableName="queueName" value="${urgentQueueName}" doc:name="queueName"/>
</when>
<otherwise>
<set-variable variableName="queueName" value="${lowPriorityQueueName}" doc:name="queueName"/>
</otherwise>
</choice>
<!--logger message="Deposit message into queue named #[variable:queueName]" doc:name="Test Flow logging" level="INFO"/-->
<jms:outbound-endpoint queue="#[variable:queueName]"
connector-ref="EnqueueJmsConnector">
</jms:outbound-endpoint>
</sub-flow>
Upvotes: 1
Views: 725
Reputation: 33413
In the jms:outbound-endpoint
, use #[queueName]
instead of #[variable:queueName]
Also no need to use a choice router to emulate a ternary expression, just use:
<set-variable variableName="queueName"
value="#[h = message.inboundProperties['myheader']; h == empty || h != 'urgent' ? '${lowPriorityQueueName}' : '${urgentQueueName}']"/>
Upvotes: 1