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