简体   繁体   中英

Is there a way to cancel a Mirth Channel destination file writer?

Is there a way to cancel a Mirth Channel destination file writer when no data has been returned. I do not want to create a file each time the channel is run. The channel need to run every 2-5 mins to process any pending records in the queue located in sql server.

I am using a Mirth channel to query a sql server database and output the data as a CSV file. I am using Mirth Connect Server 3.2.0.7628.

Here is my script on the destination transformer. I've tried to skip adding to tmp if result.Size() is not greater then zero. Could not find this use case in the Mirth Connect documentation.

var dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sqlserver://xx.xx.x.xx:1433/<dbname>',<user>,<password>);

var result1 = dbConn.executeCachedQuery("exec [z_stored_procedure] param1");

var i = 0;  
if (result1.size()>0)   
{   logger.debug(result1.size())
    while(result1.next())
    {        
          tmp.row += <row>
           <DataField1>"{result1.getString('DataField1')}"</DataField1>
           <DataField2>"{result1.getString('DataField2')}"</DataField2>                                            
          </row>; 
      } 
}

dbConn.close();

You can always exclude that destination from processing the message.

For instance if a channel has many destinations and each message only needs to be processed by a single destination, by calling destinationSet.removeAllExcept(connectorName) in the source transformer, only that destination will receive the message. Those destinations will have no data stored and will not show up in the Message Browser. This is an alternative to filtering on each destination and can save processing time and disk space.

It should work to put your code in the Destination Filter rather than the Transformer .

After your if statement, add an:

else {
return false;
}

If you have data it will run your transformation and pass it to the Destination. If you don't it will filter the message and do nothing to the Destination.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM