2018-11-30 13:50:49 +01:00
|
|
|
<!--
|
|
|
|
Copyright JS Foundation and other contributors, http://js.foundation
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
|
|
|
|
2020-01-15 03:40:48 +01:00
|
|
|
<script type="text/html" data-help-name="switch">
|
2018-11-30 13:50:49 +01:00
|
|
|
<p>Route messages based on their property values or sequence position.</p>
|
|
|
|
<h3>Details</h3>
|
|
|
|
<p>When a message arrives, the node will evaluate each of the defined rules
|
|
|
|
and forward the message to the corresponding outputs of any matching rules.</p>
|
|
|
|
<p>Optionally, the node can be set to stop evaluating rules once it finds one
|
|
|
|
that matches.</p>
|
|
|
|
<p>The rules can be evaluated against an individual message property, a flow or global
|
2019-06-07 14:39:12 +02:00
|
|
|
context property, environment variable or the result of a JSONata expression.</p>
|
2018-11-30 13:50:49 +01:00
|
|
|
<h4>Rules</h4>
|
|
|
|
<p>There are four types of rule:</p>
|
|
|
|
<ol>
|
|
|
|
<li><b>Value</b> rules are evaluated against the configured property</li>
|
|
|
|
<li><b>Sequence</b> rules can be used on message sequences, such as those
|
|
|
|
generated by the Split node</li>
|
|
|
|
<li>A JSONata <b>Expression</b> can be provided that will be evaluated
|
|
|
|
against the whole message and will match if the expression returns
|
|
|
|
a true value.</li>
|
|
|
|
<li>An <b>Otherwise</b> rule can be used to match if none of the preceeding
|
|
|
|
rules have matched.</li>
|
|
|
|
</ol>
|
|
|
|
<h4>Notes</h4>
|
|
|
|
<p>The <code>is true/false</code> and <code>is null</code> rules perform strict
|
|
|
|
comparisons against those types. They do not convert between types.</p>
|
2020-07-10 19:08:40 +02:00
|
|
|
<p>The <code>is empty</code> and <code>is not empty</code> rules passes for Strings, Arrays and Buffers that have
|
|
|
|
a length of 0, or Objects that have no properties. It does not pass for <code>boolean</code>, <code>null</code>
|
2018-11-30 13:50:49 +01:00
|
|
|
or <code>undefined</code> values.</p>
|
|
|
|
<h4>Handling message sequences</h4>
|
|
|
|
<p>By default, the node does not modify the <code>msg.parts</code> property of messages
|
|
|
|
that are part of a sequence.</p>
|
|
|
|
<p>The <b>recreate message sequences</b> option can be enabled to generate new message sequences
|
|
|
|
for each rule that matches. In this mode, the node will buffer the entire incoming
|
|
|
|
sequence before sending the new sequences on. The runtime setting <code>nodeMessageBufferMaxLength</code>
|
|
|
|
can be used to limit how many messages nodes will buffer.</p>
|
|
|
|
</script>
|