web stats
Reprocess an http sender message on a 401 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2016, 05:32 AM
GregDit GregDit is offline
Mirth Newb
 
Join Date: Feb 2016
Posts: 12
GregDit is on a distinguished road
Default Reprocess an http sender message on a 401

First: What is the proper way to get the http status code in the response transformer? I'm splitting the responseStatusLine, but not sure if there is a better way.

Second: If I get a 401, I'd like to "fetch" the new credentials and reprocess or resend the original message. Is this possible? Could it be queued? Not using a queue, but could if that is necessary.

Right now, I'm using javascript Response Transformer to handle the 401 and not sure that is even appropriate.


Thanks,

-GregD
Reply With Quote
  #2  
Old 03-29-2016, 07:52 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Yep, responseStatusLine is what you'd want to use. And yes, you can "fetch" the credentials however you want. In order to resend the message, turn queuing on, and then return QUEUED in the response transformer. You would want to use replacement variables for the credentials, and then replace them in the channel/connector map in the response transformer.
__________________
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
  #3  
Old 03-31-2016, 05:14 AM
GregDit GregDit is offline
Mirth Newb
 
Join Date: Feb 2016
Posts: 12
GregDit is on a distinguished road
Default

okay, what do you mean by return "QUEUED"? Does the Response transformer js expect a status type return?

I can't seem to reprocess the message.

if( retStatus == 401 )
{
var new_password = fetch_password();
globalChannelMap.put("password-var-used-in-http-connector", new_password);
logger.debug("Set/Return QUEUED"); //How does this really work???????????????
return;
}

Pseudo code above is in the first java-script response transformer step. It is being hit when a 401 is returned, but not working. Either the reprocessing the message is not happening because I'm not triggering the right way. Or the new value of the variable is not being set by the put method or it is not retrieved in the http connector.

Last edited by GregDit; 03-31-2016 at 06:08 AM.
Reply With Quote
  #4  
Old 03-31-2016, 10:28 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Sorry, I meant that you can set the response status to QUEUED. Look at the Response Transformer category of reference templates.
__________________
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 03-31-2016, 11:35 AM
GregDit GregDit is offline
Mirth Newb
 
Join Date: Feb 2016
Posts: 12
GregDit is on a distinguished road
Default

Thanks, it works now.

Oh, I may have found a bug. version 3.3.2.7911. When I process the http response I build an ORU message to send to another channel. I use the current channelName + '-outbound' string. Just a convention to make it easier to code. Anyway, the channelName value becomes null when I process the http 401 and queue the message again. So, to get around this I just added it to the globalChannelMap in the deploy script.

old code (that revealed channelName was null when re-queueing the messages after the 401):

var outboundChannel = channelName + '-outbound';
logger.debug("Send OBU to: " + outboundChannel);
router.routeMessage(outboundChannel,SerializerFact ory.getSerializer('HL7V2').fromXML(tmp));

new code (using a globalChannelMap hash key)

var outboundChannel = globalChannelMap.get("outbound-channel-name");
logger.debug("Send OBU to: " + outboundChannel);
router.routeMessage(outboundChannel,SerializerFact ory.getSerializer('HL7V2').fromXML(tmp));
Reply With Quote
  #6  
Old 03-31-2016, 11:46 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

That might be related to MIRTH-3860.
__________________
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
Reply

Tags
401, error, http, reprocess

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 05:08 PM.


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