web stats
Source 'Move to Error Directory' is not workin - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2018, 12:49 PM
rdemyan rdemyan is offline
What's HL7?
 
Join Date: Jun 2018
Posts: 2
rdemyan is on a distinguished road
Default Source 'Move to Error Directory' is not workin

Mirth Connect Server 3.5.0.8232

I am processing XML and in the <Source><Edit Filter> I am validating against XSD files and catch the error. If there is an error I want to write it to the directory '/mnt/var/...failed' It correctly validates and the error is written to the log/alert sent, the file does (correctly) not pass to the destination (Channel Reader), but it does not write it to the error directory.

Here are my settings:
Connector Type: File reader
Response Auto-generate(After source transformer)
Process Batch: No
Max Processing threads

File Reader
Method: file
filename *.xml

After Processing action: move
Move to directory mnt/var.../archive
move to filename: ${originalFilename}_${SYSTIME}
Error Reading Action: move
Error in Response Action: move
Error Move-to-Directory: mnt/var..../failed
Error move-to-filename: ${originalFilename}_${SYSTIME}

Last edited by rdemyan; 06-12-2018 at 07:01 AM. Reason: typo
Reply With Quote
  #2  
Old 06-11-2018, 05:22 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 252
agermano is on a distinguished road
Default

That option is for errors while reading the file. Since you are already processing the contents of the file, it was read correctly. One option would be to use the following from your filter:
Code:
var filename = $('fileDirectory') + '/failed/' + $('originalFilename') + '_' + java.lang.System.currentTimeMillis();
FileUtil.write(filename, false, connectorMessage.getRawData());
A more flexible solution would be to create a second destination to handle your messages that don't validate, but that would not cause the source message to ERROR (or FILTER?) then. You could put your validation logic in the source transformer and use a DestinationSet filter so that only the intended destination will run.

Last edited by agermano; 06-11-2018 at 05:26 PM.
Reply With Quote
  #3  
Old 06-12-2018, 07:05 AM
rdemyan rdemyan is offline
What's HL7?
 
Join Date: Jun 2018
Posts: 2
rdemyan is on a distinguished road
Default

I thought the options are - if it can not read the file and second is if it has an error.
Reply With Quote
  #4  
Old 06-12-2018, 10:18 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 252
agermano is on a distinguished road
Arrow

I'm sorry, you are correct. The Error in Response Action should look at the response. That's assuming you have a response. I think HL7v2 is the only default data type that is able to auto-generate a response. For XML you will have to generate the response.

In your filter, I would do something like the following:

Code:
var isValid, validationResponse;

// set isValid to true or false in your filter logic

if (isValid) {
  validationResponse = "Validation Passed";
}
else {
  validationResponse = new Response(Status.ERROR, "Validation Failed");
}
$r('validationResponse', validationResponse);
return isValid;
Then pick validationResponse as your response instead of auto-generate. I think this should work.
Reply With Quote
Reply

Tags
edit filter, error handling, source

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 03:29 AM.


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