web stats
sourceMap to pass message parameter accross multiple channels - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-22-2017, 05:19 AM
gribo gribo is offline
What's HL7?
 
Join Date: May 2017
Posts: 5
gribo is on a distinguished road
Unhappy sourceMap to pass message parameter accross multiple channels

Hi,

I would like to pass parameters to message along multiple channels. I don't know the names of the channel that will process my messages in advance because we do dynamic routing of message.

I think sourceMap is designed for that, but i'm facing 2 major issues :

sourceMap seems read-only in the javascript source/destination transformation and I wonder why ?

sourceMap seems cleared between channels, using router.route('channel', message)
The only way it seems to work is by creating a new message each time using :
router.routeMessage('channel', new RawMessage(connectorMessage.getRawData(), null, connectorMessage.getSourceMap() ));

Am I missing something or is there another design I did not see to pass parameter per message to multiple channels ?

Regards,
Reply With Quote
  #2  
Old 05-22-2017, 06:42 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,117
narupley is on a distinguished road
Default

First, since you did not specify, I'm going to assume that you're working with the latest version (3.5.0).

You can still do dynamic message routing and inject source map variables all with the standard Channel Writer. The Channel Id field supports Velocity variable replacement.

The Message Metadata table allows you to set variable names to inject into the downstream channel message. For example if you add "key" into that table (without the quotes), then when your message is dispatched the channel will look for the key "key" in any available maps (connector/channel/source/global channel/global/configuration/response) and inject the value it finds into the source map of the downstream message.

Quote:
Originally Posted by gribo View Post
sourceMap seems read-only in the javascript source/destination transformation and I wonder why ?
That is intentional. There is no need or purpose to modifying the source map.

Quote:
Originally Posted by gribo View Post
sourceMap seems cleared between channels, using router.route('channel', message)
The only way it seems to work is by creating a new message each time using :
router.routeMessage('channel', new RawMessage(connectorMessage.getRawData(), null, connectorMessage.getSourceMap() ));
The source map is not "cleared between channels". Like the connector and channel maps, it is tied to a specific message. The code you posted is the correct method for injecting source map variables into a downstream channel using manual JavaScript, but you don't have to use connectorMessage.getSourceMap(). You could also create a whole new Map and inject whatever you want.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 05-23-2017, 01:06 AM
gribo gribo is offline
What's HL7?
 
Join Date: May 2017
Posts: 5
gribo is on a distinguished road
Smile

Thank you very much, it is much clear now and working fine. I use 3.4.2 for now but plan to migrate to 3.5.x in a couple of weeks.

I have another question regarding the following line :
Code:
router.routeMessage('channel', new RawMessage(connectorMessage.getRawData(), null, connectorMessage.getSourceMap() ));
How can I route the existing message without having to create a new one ?


And in case it is not possible, what could I put instead of null in the second parameter for destinationMetaDataIds ? Or is it ok to leave the field as null ?

Regards
Reply With Quote
  #4  
Old 05-23-2017, 06:24 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,117
narupley is on a distinguished road
Default

You don't have to create a new RawMessage object, if all you need to send is the message string. The RawMessage object is used when you also want to inject source map variables or pre-set the destination set filter. Null is perfectly fine for that second parameter.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Tags
sourcemap parameter

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:18 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation