No announcement yet.

Channel Map vs Connector Map vs Global Map

  • Filter
  • Time
  • Show
Clear All
new posts

  • Channel Map vs Connector Map vs Global Map

    Do I understand this correctly?

    The different mappings are just the scope of the mapping??

    Channel Map = just in this channel
    Connector Map = just in this connector
    Global Map = across the entire application
    Response Map = just for the response

  • #2
    Re: Channel Map vs Connector Map vs Global Map

    You've got it correct.
    Chris Lang


    • #3
      Re: Channel Map vs Connector Map vs Global Map

      What is the scope of the Response Map? Is it within just scope of the "current" message?

      If two messages are in a channel at the same time (assuming they can they be), isn't Channel Map the wrong place to put temporary message values?

      Basicly I need a clear, unambigious definition of all the maps.


      • #4
        Re: Channel Map vs Connector Map vs Global Map

        The channelMap only exists in the scope of a single message in the channel. It actually "lives" in the message object, same as the response map.

        The connector map is local for each connector (so the source and any destinations).

        Here is the actual object flow in the Mirth code:

        Message is Received->Message Object is Created (includes channel map, response map and the source connector's connector map)->Message Object is duplicated for each destination (retains a SINGLE reference to the channel map and response map, however a new connector map is created for each copy of the message object).

        When you reference any of the maps in your JS, you are referencing the maps that live on that message object.

        The only map that is shared between messages is the global map.
        Chris Lang


        • #5
          Re: Channel Map vs Connector Map vs Global Map

          In the case where the message is routed to another channel, are new channel & response maps created or are the still referenced to the original ones?

          Out of curosity, what is the difference between the channel & response maps? They seem to have the the same scope, etc.


          • #6
            Re: Channel Map vs Connector Map vs Global Map

            They will be new maps when its routed to new channel.

            They do have the same scope. They are just for separation of concerns.
            Brendan Haverlock | Mirth Software Engineer | Mirth Corporation


            • #7
              Re: Channel Map vs Connector Map vs Global Map

              Right, completely new maps and messages are created (duplicated content).

              Same scope as Brendan said - the response map is automatically populated with an entry for each destination (which you can override).
              Chris Lang


              • #8
                Re: Channel Map vs Connector Map vs Global Map

                Now the picture is becoming clearer - thanks!


                • #9
                  Map that will be available in Message reception

                  My use case is to process a set of results from a query as one data set. For implementing this, I want to loop through this result set (using Javascript) and create a map that I can use in the source transformer.

                  I am not sure if this will work. Looks like Mirth expects a result set and processes one result at a time. In my case I need to fake by returning a artificial resultset that has only one result.

                  But the actual problem looks like that no map is visible in the source connector. Is this because there is no message object created at this point.

                  How can I put the values that I got from multiple rows into a map that will be visible in source transformer?

                  Can you give your thoughts?

                  Thanks in advance.


                  • #10
                    kbobba, rather than returning a resultset, you can return a different type of set. I believe you can return a list of hash maps. Each item in the list will be processed as a message, and each item in the hash map will be accessible in the source transformer as the incoming xml message.
                    Jacob Brauer
                    Director, Software Development
                    NextGen Healthcare



                    • #11
                      why source connector can't use channelMap.put()?


                      I use js writer as source connector. I want use a channelmap to store a value and using in other destionation. but say:

                      2: function $c(key, value) { if (arguments.length == 1) { return channelMap.get(key); } else { return channelMap.put(key, value); } }
                      3: function $s(key, value) { if (arguments.length == 1) { return sourceMap.get(key); } else { return sourceMap.put(key, value); } }
                      4: function $gc(key, value) { if (arguments.length == 1) { return globalChannelMap.get(key); } else { return globalChannelMap.put(key, value); } }
                      5: function $g(key, value) { if (arguments.length == 1) { return globalMap.get(key); } else { return globalMap.put(key, value); } }
                      6: function $cfg(key, value) { if (arguments.length == 1) { return configurationMap.get(key); } else { return configurationMap.put(key, value); } }
                      7: function $r(key, value) { if (arguments.length == 1) { return responseMap.get(key); } else { return responseMap.put(key, value); } }
                      8: function $(string) { try { if(responseMap.containsKey(string)) { return $r(string); } } catch(e){}try { if(connectorMap.containsKey(string)) { return $co(string); } } catch(e){}try { if(channelMap.containsKey(string)) { return $c(string); } } catch(e){}try { if(sourceMap.containsKey(string)) { return $s(string); } } catch(e){}try { if(globalChannelMap.containsKey(string)) { return $gc(string); } } catch(e){}try { if(globalMap.containsKey(string)) { return $g(string); } } catch(e){}try { if(configurationMap.containsKey(string)) { return $cfg(string); } } catch(e){}try { if(resultMap.containsKey(string)) { return resultMap.get(string); } } catch(e){}return ''; }
                      9: function getAttachments() {return AttachmentUtil.getMessageAttachments(connectorMess age);}
                      10: function addAttachment(data, type) {
                      LINE NUMBER: 2
                      DETAILS: ReferenceError: "channelMap" is not defined.
                      at 4ca00210-4f2d-4a41-a980-05eb61b2ff00:2 ($c)
                      at 4ca00210-4f2d-4a41-a980-05eb61b2ff00:44 (doScript)
                      at 4ca00210-4f2d-4a41-a980-05eb61b2ff00:47
                      at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(
                      at com.mirth.connect.connectors.js.JavaScriptReceiver $ va:159)
                      at a:266)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(
                      at java.util.concurrent.ThreadPoolExecutor$ (


                      • #12
                        There is no channel map available in the JavaScript Reader, because there is no message yet. The job of the JavaScript Reader is to create messages for the channel to consume (or just execute an arbitrary block of code).

                        The JavaScript Writer is different. It's a destination connector, so in there you do have access to the channel map.

                        If you want to pass metadata along with your messages in the JavaScript Reader, you can return a RawMessage object (or list of said objects), including a map of variables to inject into the source map. More info in the User API.
                        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.