Announcement

Collapse
No announcement yet.

Channel Errors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Channel Errors

    I'm implementing some error handling for a channel but not entirely sure where would be the best place to handle it...

    I have a channel that directs messages to other channels as a channel writer, and I have a particular channel as a channel reader with a destination that then sends those messages to a web service.

    What I'm looking to do is if there is an error with the destinations, say the web service is down and couldn't connect to it, I would like to capture a copy of the original hl7 message. Currently, if there's any problems with the destinations the message gets lost (as far as I can tell).

    I can already handle error responses that come back as soap xml, looking to handle errors thrown by Mirth when trying to process a message.

    I did a bit of looking around and I came across two potential ways of doing this...setting up an error filter or handling the error in the postprocessor. Also, I saw a "Response Object" mentioned but not sure how to work with the object. Is there documentation on that somewhere?

    Could anyone suggest the best way to go about what I'm trying to accomplish? I'm currently working with version 2.2.
    Last edited by skekasaurus; 05-08-2014, 08:07 AM.
    Mirth Connect v3.2.2
    Java 8
    SQL Server 2005

  • #2
    Yes, the best place to do that is the postprocessor. You can grab the responses from destinations in the response map. For example, "responseMap.get('Destination 1')". That will return a Response object, and you can call getStatus() or getMessage() on it to retrieve the status or response payload (if any). In the postprocessor you can call "messageObject.getRawData()" to retrieve the original source raw message.
    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.

    Comment


    • #3
      Somewhat related to this, but now that I'm in 3.0 and can now use a response transformer, how am I able to capture the errors that may occur should the javascript break?

      For exception errors that occur in a destination's transformer, in the postprocessor I'm able to get the status using:

      Code:
      responseMap.get('destination 1').getStatus();
      But when I throw an exception in the response transformer, I get:

      Code:
      TypeError: Cannot call method "getStatus" of null
      Mirth Connect v3.2.2
      Java 8
      SQL Server 2005

      Comment


      • #4
        Yes that makes sense. Since an error occurred in the response transformer, no response entry will exist for that destination in the response map.

        You should not be throwing an error manually in the response transformer. Just set the status to ERROR instead. There are templates in the References tab already for that.
        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.

        Comment


        • #5
          Originally posted by narupley View Post
          Yes that makes sense. Since an error occurred in the response transformer, no response entry will exist for that destination in the response map.

          You should not be throwing an error manually in the response transformer. Just set the status to ERROR instead. There are templates in the References tab already for that.
          Well I won't normally be throwing errors manually, I wanted to test what would happen if something do go awry. In the response transformer I'll be sending off emails based on the response I get back from sending to a web service. So should the code that parses the SOAP envelope, or the sending of the HTML email not work, I would like some way for someone to be aware of the current error.
          Mirth Connect v3.2.2
          Java 8
          SQL Server 2005

          Comment


          • #6
            Originally posted by skekasaurus View Post
            Well I won't normally be throwing errors manually, I wanted to test what would happen if something do go awry. In the response transformer I'll be sending off emails based on the response I get back from sending to a web service. So should the code that parses the SOAP envelope, or the sending of the HTML email not work, I would like some way for someone to be aware of the current error.
            In that case, a good course of action would be to wrap your code in a try..catch, and in the catch block you can manually set the response status to ERROR, or modify the response status message or error content itself.
            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.

            Comment


            • #7
              Gotcha!!! Thanks Nick, always appreciate your help.
              Mirth Connect v3.2.2
              Java 8
              SQL Server 2005

              Comment

              Working...
              X