Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Checking,if channel is currently running, using JS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Checking,if channel is currently running, using JS

    Hello all,

    I have a channel that reads from a DB and updates some datasets, using javascript. The problem is, that my channel should update some datasets if another particular channel is currently running.

    Some kind of:

    if (secondChannelIsRunning) {
    updateParticularTable
    }

    Do you know how to check if the second channel is currently running, using JS?

    Thanks a lot!!

    Svetlomir

  • #2
    Re:Checking,if channel is currently running, using

    Hey,

    I set up two channels, one is called "CreateSegments", and the other "UpdateIfOtherChannelRunning". In the second channel, I have a "Javascript Reader" as my Source and its polling every 5 seconds for the channel "CreateSegments". You can rework the following code to suit your needs (i.e. update a db):

    Code:
    importPackage(Packages.com.webreach.mirth.server.controllers); 
    var controller = ChannelStatusController.getInstance(); 
    var status = controller.getChannelStatusList();
    var OtherChannelName = "CreateSegments";
    
    for (var i=0; i < status.size(); i++){
    	if (status.get(i).getName() == OtherChannelName){ 
    		logger.info("Found Other Channel!"«»);
    	}
    }
    UpdateIfOtherChannelRunning.xml (3638 bytes)

    Comment


    • #3
      Re:Checking,if channel is currently running, using

      Actually, you probably wanna check to see if that channel was started, so change the if statement to:

      Code:
      if (status.get(i).getName() == OtherChannelName && status.get(i).getState() == "STARTED"«»)

      Comment


      • #4
        Re:Checking,if channel is currently running, using

        Thank you zzoubian!!!

        I'll try it!

        Regards,

        Svetlomir

        Comment

        Working...
        X