JavaScript Reader Return Values
If you are using the JavaScript Reader to produce messages for the channel, all you need to do is return those messages from the script. The following return values are accepted:
- String: Any non-empty string returned will be sent to the channel as a message.
- RawMessage: This is a special object that contains not only the string message data, but also information about which destinations to dispatch to, and any source map variables you wish to inject. For additional information, see The User API (Javadoc).
- List: If a Java List is returned, all values in the list will be sent to the channel as discrete messages. The list may contain a mix of Strings, RawMessage objects, or other objects.
- Empty String / null / undefined: Returning any of these (including just a "return;" statement or no return statement at all) will cause no messages to dispatch to the channel.
- Any Object: Any other object returned will be converted to a String via the toString() method, and that String representation will be sent to the channel as a message.