Skip to content

Commit

Permalink
Update router.routeMessage.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pacmano1 authored Sep 9, 2024
1 parent b2389d3 commit 430ddaa
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions router.routeMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,43 @@
* @author Tony Germano
* @description
* This file contains utility functions for routing messages in Mirth Connect.
* These functions simplify the process of routing messages by abstracting away
* the details of creating raw messages and routing them to the appropriate channel.
* It simplifies routing by automatically creating `RawMessage` objects and
* including necessary metadata, replicating the behavior of Channel Writer destinations.
*
* # Route with Sources
*
* Mirth provides two ways to send messages from one channel to another. The simple way is by using a
* Channel Writer destination. This lets you choose your destination channel, set optional "Message
* Metadata," which will appear in the sourceMap of the new message, and create a template for the
* message.
*
* The second method is by using the `VMRouter` class from the User API. Mirth automatically inserts
* an instance of this class into the top-level JavaScript scope named `router`. You can send metadata
* with your messages using this method as well, but it is slightly more complicated as it requires
* constructing a `RawMessage` to pass to the route command.
*
* Additionally, when you use a Channel Writer, it automatically inserts metadata into the sourceMap
* representing the current channel and message, as well as any prior channels and messages that may
* have participated in the message chain. This functionality does not exist when using the `router`
* object to send messages.
*
* This library aims to make sending messages from JavaScript as easy as using a Channel Writer, while
* also incorporating the same channel and message tracking capabilities.
*
* This is accomplished through three related functions. See the source of each function for full
* usage:
*
* - **createRawMessage:** This creates an instance of `RawMessage` as specified in the Mirth User API.
* Additionally, it mimics the behavior of a Channel Writer destination and appends metadata to the
* sourceMap of the `RawMessage` by incorporating the `channelId` and `messageId` from the current
* JavaScript context, if present.
*
* - **routeMessage:** Wrapper for `router.routeMessage`, which calls `createRawMessage` from this library
* before sending the message. There are optional parameters to pass a sourceMap as the seed for the one
* created by `createRawMessage` and for the `destinationSet` to be used by `createRawMessage`.
*
* - **routeMessageByChannelId:** This is the same as the `routeMessage` function from this library except it
* wraps `router.routeMessageByChannelId`.
*/

/**
Expand Down

0 comments on commit 430ddaa

Please sign in to comment.