Sleep method in Mirth

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());

4 comments on “Sleep method in Mirth

  1. Shamil says:

    Just as a recommendation on a follow up reading, I would suggest an “Unofficial Mirth Connect developer’s guide” book available to download at
    (Disclaimer: I’m an author of this book, so any comments or suggestions are welcome.)

  2. Glenn Elliott says:

    this works with mirth.. avoids cpu loops

    java.lang.Thread.sleep(3000); // 3 seconds delay

  3. click here says:

    Yes! Finally someone writes about google.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s