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.

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.

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.

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.

Comment

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

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.

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.

We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, personalize advertising, and to analyze site activity. We may share certain information about our users with our advertising and analytics partners. For additional details, refer to our Privacy Policy.

By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.