There are situations where in you will configure your source connector as “Database Reader”.
Assuming you define a polling frequency of 10seconds.
Now at the source transformer level, you write several lines of java script code to interact further with data values fetched from the query defined at source connector level.
This may crash the Database server, as the polling frequency is pretty less and it fires the query immediately because you have defined them at the connector level.
You can save yourself in many ways, but I feel this sounds more suitable to implement a delay as the very first transformer (Step 1 among all your steps).
Below is the java script code; can be embedded into any source transformer in Mirth.
function dummySleep(delay) { //channelMap.put("Beforetime", new Date().getTime().toString()); var start = new Date().getTime(); while (new Date().getTime() < start + delay); //channelMap.put("aftertime", new Date().getTime().toString()); }
Just as a recommendation on a follow up reading, I would suggest an “Unofficial Mirth Connect developer’s guide” book available to download at http://mirthconnect.isarp.com
(Disclaimer: I’m an author of this book, so any comments or suggestions are welcome.)
this works with mirth.. avoids cpu loops
java.lang.Thread.sleep(3000); // 3 seconds delay
Thanks Glenn! Yours’ code is optimized one – I had a note on this.
Yes! Finally someone writes about google.