Skip to content

Commit

Permalink
Create router.routeMessage.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pacmano1 authored Sep 9, 2024
1 parent 5243212 commit 22fa8a8
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions router.routeMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @file routeMessageFunctions.js
* @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.
*/

/**
* Routes a message to a specified channel by name.
*
* @param {string} channelName - The name of the channel to which the message should be routed.
* @param {Object} message - The message to be routed.
* @param {Object} sourceMap - The source map containing metadata or properties related to the message.
* @param {Object} destinationSet - The destination set specifying where the message should be routed.
* @returns {Object} - The result of the routing process.
*
* @example
* const result = routeMessage('MyChannel', message, sourceMap, destinationSet);
*/
function routeMessage(channelName, message, sourceMap, destinationSet) {
return router.routeMessage(channelName, createRawMessage(message, sourceMap, destinationSet));
}

/**
* Routes a message to a specified channel by ID.
*
* @param {string} channelId - The ID of the channel to which the message should be routed.
* @param {Object} message - The message to be routed.
* @param {Object} sourceMap - The source map containing metadata or properties related to the message.
* @param {Object} destinationSet - The destination set specifying where the message should be routed.
* @returns {Object} - The result of the routing process.
*
* @example
* const result = routeMessageByChannelId('1234abcd', message, sourceMap, destinationSet);
*/
function routeMessageByChannelId(channelId, message, sourceMap, destinationSet) {
return router.routeMessageByChannelId(channelId, createRawMessage(message, sourceMap, destinationSet));
}

0 comments on commit 22fa8a8

Please sign in to comment.