web stats
How can I use queue mechanism - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-24-2013, 10:48 AM
sagarshah1983 sagarshah1983 is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 68
sagarshah1983 is on a distinguished road
Default How can I use queue mechanism

Hello all,
I am new to mirth and using Mirth 3.0.0.6931 version.
I have created a channel that is basically doing following.
- Polling for records from database with a flag
- Updating the flag to "PROCESSED" so that it won't be picked up again
- Transform message in xml format
- Send message to an external system

I want to take the benefit of queue mechanism of Mirth 3.0 so that when external system is down for whatever reason, I not only log the details of this message, but also keep the message in some queue and process it, when external system is up and running (it could be based on retry attempts or pinging to external system at frequent intervals).

Importantly, no message should be lost and I should be able to track every message being sent to my original channel.

Do anyone have any input or experience to share on how I can implement this feature here?

Any help is very much appreciated.

Regards,
Sagar Shah

Last edited by sagarshah1983; 10-24-2013 at 10:54 AM. Reason: To subscribe for email notification
Reply With Quote
  #2  
Old 10-24-2013, 12:18 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,115
narupley is on a distinguished road
Default

All destination connectors in 3.0 have the ability to queue, so you just need to turn queuing on for your destination (select "Attempt First" or "Always").
__________________
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 10-24-2013, 12:51 PM
sagarshah1983 sagarshah1983 is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 68
sagarshah1983 is on a distinguished road
Default

Thanks much for quick reply. So as I understand there's a mechanism already supported for any type of destinations in Mirth 3.0.
Also, I should be able to set status of my processing in a custom way so as to indicate whether message processing is successful or not and accordingly mirth will decide whether or not to reprocess the message, correct?
Considering that I will be using java script writer to send message to external system, can you please help me understand, how I can set the processing status to SENT/ERROR, so that mirth determines whether or not to reprocess the message?

Appreciate your help!
Reply With Quote
  #4  
Old 10-24-2013, 12:52 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,115
narupley is on a distinguished road
Default

Quote:
Originally Posted by sagarshah1983 View Post
Thanks much for quick reply. So as I understand there's a mechanism already supported for any type of destinations in Mirth 3.0.
Also, I should be able to set status of my processing in a custom way so as to indicate whether message processing is successful or not and accordingly mirth will decide whether or not to reprocess the message, correct?
Considering that I will be using java script writer to send message to external system, can you please help me understand, how I can set the processing status to SENT/ERROR, so that mirth determines whether or not to reprocess the message?

Appreciate your help!
From a JavaScript Writer, by default if you don't return anything the status will be SENT. If you want to err out the message, do "return ERROR;". If you want to queue the message (and queuing is enabled for the destination), do "return QUEUED;".
__________________
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 10-24-2013, 12:53 PM
sagarshah1983 sagarshah1983 is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 68
sagarshah1983 is on a distinguished road
Default

That was pretty quick! I will try this out.
Thanks for your help.
Reply With Quote
  #6  
Old 10-30-2013, 07:56 AM
sagarshah1983 sagarshah1983 is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 68
sagarshah1983 is on a distinguished road
Default

Hello Narupley,
I just tried the options you suggested, but it does not seem to work the way I was expecting. Can you please help me understand what I could be missing.
I am attaching channel source code for reference.

To describe -
I have a channel source as channel reader and destination as java script writer.
I am pushing a message to channel and running some logic in javascript (basically sending it to another REST service using code template).
If this calls fails, the message is put in QUEUED and if it works well then it puts in SENT.

Upto here, everything seems to be working fine.

But it does not seem to pick this message again for retry, which are QUEUED, when external REST URL is NOT working fine.(Though I see updated timestamp for Response Data in Mirth message dashboard for this channel).

I have put up some logger statements as well just to see, if its running or processing the message again after it went in QUEUED category, but apparently it does not.

Appreciate your advice.
Attached Files
File Type: xml RequeueTest.xml (12.1 KB, 75 views)
Reply With Quote
  #7  
Old 10-30-2013, 08:00 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,115
narupley is on a distinguished road
Default

You need to move that transformer code to the JavaScript Writer. When a message is queued on a destination, the filter/transformer does not run again, only the actual dispatch.
__________________
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 10-30-2013, 08:53 AM
sagarshah1983 sagarshah1983 is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 68
sagarshah1983 is on a distinguished road
Default

That worked like a magic trick for me. Awesome. Thanks a ton for prompt solution.
Just one more question, I am not sure about option "Regenerate Template" and what are the implications of the same. Can you please explain this for me.
If I check this, does it have anything to do with reprocessing something or memory.
Any scenario, which you can think of, where this should be useful.

Again.. Thanks a ton.

Regards,
Sagar Shah
Reply With Quote
  #9  
Old 10-30-2013, 09:20 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,115
narupley is on a distinguished road
Default

Quote:
Originally Posted by sagarshah1983 View Post
That worked like a magic trick for me. Awesome. Thanks a ton for prompt solution.
Just one more question, I am not sure about option "Regenerate Template" and what are the implications of the same. Can you please explain this for me.
If I check this, does it have anything to do with reprocessing something or memory.
Any scenario, which you can think of, where this should be useful.

Again.. Thanks a ton.

Regards,
Sagar Shah
From the tool-tip for that component:

Quote:
Regenerate the template and other connector properties by replacing variables each time the connector attempts to send the message from the queue. If this is disabled, the original variable replacements will be used for each attempt.
This is applicable for pretty much anything but the JavaScript Writer, because that's the only destination which doesn't have replaceable fields.
__________________
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
  #10  
Old 10-30-2013, 09:32 AM
sagarshah1983 sagarshah1983 is offline
OBX.2 Kenobi
 
Join Date: Oct 2013
Posts: 68
sagarshah1983 is on a distinguished road
Default

Sorry to bother again, but did not get much from tooltip.
So here I am putting the scenario.
For that same channel, I might be willing to send data 2 destinations using java script writer to 2 different external applications.
I will have a different set of transformers for each destination that will put the data in required format in channelMap as per each external application need.
Both this destinations will have queueing enabled.
So 2 questions...
1. If 1 of the destinations fails to send data, it will be queued and only that destination will be retried again, right? My guess is Yes.
2. Will checking or unchecking of "Regenerate Template" make any difference as long as both are java script writers? My guess is No.

Appreciate your advice.
Thanks.
Reply With Quote
Reply

Tags
mirth 3.0, queues

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 02:48 AM.


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