web stats
Wait on response for destination - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2014, 08:25 PM
shenkey shenkey is offline
Mirth Newb
 
Join Date: Aug 2011
Posts: 10
shenkey is on a distinguished road
Default Wait on response for destination

Hello,

i have a pdf reader channel that works as below,

1. source read *.hl7 from a folder
2. transformer based on the name of *.hl7 file reads the pdf file and add it to msg.
3. destination sends this modified msg.

now i want to wait in transformer to check if the msg got accepted and ack by the destination system , if the message was accepted i want to delete that particular "pdf" file and if not then i want to keep that pdf for troubleshooting. same HL7 file gets deleted by source connector once it is successfully processed.

the destination uses a queue with attempt first option.

i tried to put the delete code in response transformer for that destination and check if the message status was "SENT" but i never get that deletion code executed. it always call the else part of the code. i always get no delete.

var responsemsg =responseMap.get('name of destination').getStatus();
if(responsemsg=='SENT')
{
logger.info("Now Start");
var file = new java.io.File(DirectoryPath+$('FileName')+'.pdf');
file.delete();
}
else
{
logger.info('No delete');
}

Thank you,
Reply With Quote
  #2  
Old 07-03-2014, 06:11 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,310
cory_cole is on a distinguished road
Default

You want to put code in the post processor.
Reply With Quote
  #3  
Old 07-03-2014, 07:11 PM
shenkey shenkey is offline
Mirth Newb
 
Join Date: Aug 2011
Posts: 10
shenkey is on a distinguished road
Default

Thank you cory for the reply.

i tried that but it is still not waiting or monitor the message.
i mean by that is, if the receiving application or network is running and accept the message the pdf gets deleted fine.
but if the message gets into the queue for whatever reason like network down or application not running then it do not work. the queued messages gets sent fine after the network is back up but the delete logic do not work as it has already been executed.

Also is postprocessor individual to each destination or is it common for all?
Reply With Quote
  #4  
Old 07-07-2014, 08:09 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

If you want such logic to take place even if the message gets queued, then you can use the response transformer instead. The response transformer executes after every send attempt, and you'll have access to the status (e.g. SENT/ERROR/QUEUED) of the response to perform conditional logic against.
__________________
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
  #5  
Old 07-07-2014, 07:19 PM
shenkey shenkey is offline
Mirth Newb
 
Join Date: Aug 2011
Posts: 10
shenkey is on a distinguished road
Default

do i use Source transformer or destination response transformer?
on destination response transformer it gives error "null" do not have getStatus() method.

i moved the code to response transformer. I have "attempt first" for destination so if network is down it get queued and at time response transformer dont even get called. now when network is back up it gives below error message but message still gets sent and the response map for that message has status "SENT".

And sometimes when messages gets sent it gets response "Queued" which was previous status.


121: function doTransform() {122: 123: 124: logger.info("in response transformer");125: //var responsemsg =responseMap.get('name Practice').getStatus();126: var responsemsg = response.getStatus();127: logger.info(responsemsg);128: if(responsemsg=='SENT'){129: logger.info("Now Start");130: var file = new java.io.File(DirectoryPath+$('FileName')+'.pdf');L INE NUMBER:
126DETAILS:
TypeError: Cannot find function getStatus in object com.mirth.connect.server.userutil.ImmutableRespons e@3694903e.

This is confusing can you explain how this response transformer works.

Last edited by shenkey; 07-07-2014 at 07:51 PM.
Reply With Quote
  #6  
Old 07-09-2014, 06:15 PM
shenkey shenkey is offline
Mirth Newb
 
Join Date: Aug 2011
Posts: 10
shenkey is on a distinguished road
Default

Can someone help me with above ?
Reply With Quote
  #7  
Old 07-10-2014, 07:17 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

The response transformer runs after each send attempt, if there is an actual response payload. If there is no payload (like if there's an ACK timeout) then it will not run. The only exception is when the response inbound data type is Raw; in that case the response transformer will always run.

There are templates in the References tab specific to the response transformer, so use those.
__________________
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
  #8  
Old 07-17-2014, 10:47 PM
shenkey shenkey is offline
Mirth Newb
 
Join Date: Aug 2011
Posts: 10
shenkey is on a distinguished road
Default

Thank you for guiding me but i am still having problem.

so if the message is Queued, i will always get that error right?

Am i trying to achieve something not possible or can you provide some psudo code so that i can fix this.
Thank you
Shenkey
Reply With Quote
Reply

Tags
delete file, pdf

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 10:50 AM.


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