web stats
Alert when event does not happen - Mirth Community

Go Back   Mirth Community > Mirth Connect > General Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2018, 10:12 AM
ehobbs ehobbs is offline
Mirth Newb
 
Join Date: Jul 2011
Posts: 7
ehobbs is on a distinguished road
Default Alert when event does not happen

I've been mulling over the possible ways in which we might have Mirth notify us when something doesn't happen. For instance, a channel that takes a file from a folder every 24 hours and sends it to an FTP location. If during one polling period the file is not available, trigger an email.

I was thinking of doing some kind of write to a DB table with the last datetime that a send occurred and having another channel check this table periodically and send an email if current datetime is more than 24 hours since last datetime (or whatever interval is appropriate).

I've got a feeling I'm overthinking this and was wondering if I am missing something obvious.

Thanks for any feedback
Reply With Quote
  #2  
Old 08-17-2018, 08:37 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,097
narupley is on a distinguished road
Default

Just an FYI, this functionality is available as part of our Advanced Alerting commercial extension. There are "threshold" and "sliding window" trigger types that allow all kinds of complex logic. For example you can alert when, say, a channel has not received any messages in the past hour/day/whatever.
__________________
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 08-23-2018, 12:36 AM
hgdevanand hgdevanand is offline
OBX.1 Kenobi
 
Join Date: Apr 2015
Posts: 26
hgdevanand is on a distinguished road
Default

Hi,

You can definitely achieve it using Java script.
If while polling for file every 24 hours, if nothing is found you can invoke alerts using Javascript.

alerts.sendAlert("alert message ----");


Regards,
Dev
Reply With Quote
  #4  
Old 09-20-2018, 06:02 PM
J-Flynn J-Flynn is offline
Mirth Newb
 
Join Date: Sep 2018
Posts: 9
J-Flynn is on a distinguished road
Post

Quote:
Originally Posted by ehobbs View Post
I've been mulling over the possible ways in which we might have Mirth notify us when something doesn't happen. For instance, a channel that takes a file from a folder every 24 hours and sends it to an FTP location. If during one polling period the file is not available, trigger an email.

I was thinking of doing some kind of write to a DB table with the last datetime that a send occurred and having another channel check this table periodically and send an email if current datetime is more than 24 hours since last datetime (or whatever interval is appropriate).

I've got a feeling I'm overthinking this and was wondering if I am missing something obvious.

Thanks for any feedback
You wouldn't even need a database, technically speaking. Mirth has access to global maps and global channel maps, which would allow you a means to persist a variable over a period of time.

So, one setup you might do (pseudo-code):

Check file last seen:

Code:
if(globalMap.get('FileLastSeen') != null)
{
var LastSeen = globalMap.put('FileLastSeen');

var Difference = CurrentTime - LastSeen;

if(Difference > 2400)
{

//Do alert
alert();
//Reset the timer (optional)
globalMap.put('FileLastSeen',CurrentTime);
}


}
Then configure the channel to fire periodically (say, every hour) to check.

Then, your channel that does whatever with the file, in a Transformer, simply add:

Code:
if(FileFound)
{
//Assumes YYYYMMDDhhmmss stored as an integer format
globalMap.put('FileLastSeen',CurrentTime);
}

So you'd have two channels:
1) Does the FTP stuff, updates the timer in the globalMap
2) Periodically checks the time in the globalmap compared to current time for the file hasn't clocked over a certain amount of time

Optional:
3) Email channel (which is preconfigured to fire off a message)


I've got a system built similarly (it simply emails any errors detected within a 24 hour period on a particular set of channels to a specific group of people).
Reply With Quote
  #5  
Old 10-04-2018, 03:03 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 747
agermano is on a distinguished road
Default

The global maps are volatile, though, so keep that in mind if you base a solution around them. They may or may not persist through a redeploy, depending on your settings, and they definitely will not persist through a mirth service restart or server reboot.
Reply With Quote
Reply

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:57 PM.


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