sqlmirth

Is it possible to use a an SQL query to find out whether a Mirth channel is disabled or not?


Is it possible to use a an SQL query to find out whether a Mirth channel is disabled or not? I know it can be done via API calls but I am trying to use a purely database method.


Solution

  • Yes you can.

    SELECT * FROM public.configuration where name = 'channelMetadata'; will return an XML string which contains the channel metadata with the enabled/disabled state, last modification timestamp, and pruning options.

    These entries look like:

      <entry>
        <string>C88749A7-BDF5-45D8-AC41-DF0884B15098</string>
        <com.mirth.connect.model.ChannelMetadata>
          <enabled>false</enabled>
          <lastModified>
            <time>1621527614990</time>
            <timezone>America/Chicago</timezone>
          </lastModified>
          <pruningSettings>
            <pruneMetaDataDays>3</pruneMetaDataDays>
            <archiveEnabled>false</archiveEnabled>
          </pruningSettings>
        </com.mirth.connect.model.ChannelMetadata>
      </entry>
    

    They are a serialized Java Map<String, com.mirth.connect.model.ChannelMetadata>. The key is the channel ID, you can look that up in the channel table to find name, the channel definition itself, etc.

    Note that this shows enabled/disabled which is not the same as started/stopped. The started/stopped state is only available via API calls since its the running state of MC and kept in memory.