This project has moved. For the latest updates, please go here.

Notify On Empty Batch

Jul 15, 2009 at 3:37 PM

Does the "Notify On Empty Batch" Scheduling Property work when set to True?  Should a message appear in the application eventlog similar to what happens to system exceptions thrown by the adapter?  I am using a once a day daily schedule and have confirmed on some days there are indeed no files to be picked up from the sftp site I am connecting to but see no message displayed anywhere confirming there were no files.  On days when there are files on the site they are picked up fine. Thank you.

Coordinator
Jul 18, 2009 at 6:44 AM

No, if you enable "Notify on empty batch", the adapter will create a new error message and submit it to BizTalk.

HTH

//Mikael

Jul 19, 2009 at 5:17 PM

Thank you for your quick reply which explains to me where to expect a message.  Prior to today I had not looked at the adapter source code.  I apologize for not doing that first in an attempt to answer my own question.  I don't believe however that in the case of there being no files to be picked up from the sftp site I will ever see the EmptyBatch.xml message in BizTalk.  Prior to calling CreateEmptyBatchMessage in SftpReceiverEndpoint.cs PickupFilesAndSubmit, it looks like we return from PickupFilesAndSubmit as part of the following else clause:

if (fileEntries.Count > 0)
{
        batchHandler = new BatchHandler(sftp, this._propertyNamespace, this._transportType, this._transportProxy, this._properties.DebugTrace, this._properties.UseLoadBalancing);
        // Used for Connection pool: batchHandler.BatchComplete += new BatchHandler.BatchHandlerDelegate(batchHandler_BatchComplete);
}
else
{
         sftp.Disconnect();
         sftp.Dispose();
         sftp = null;
         // Used for Connection pool: SftpConnectionPool.GetHostByName(this._properties.SSHHost).ReleaseConnection(sftp);
         return false;
}

Coordinator
Jul 19, 2009 at 10:47 PM

You are absolutly right. I think this bug is a result of refactoring....

The code for handling the enpty batch, is put out of position. I'll fix it till the next release, but until then please use the code below:

// If batch has file enties create a BatchHandler and a new sftp connection.
if (fileEntries.Count > 0)
{
    batchHandler = new BatchHandler(sftp, this._propertyNamespace, this._transportType, this._transportProxy, this._properties.DebugTrace, this._properties.UseLoadBalancing);
    // Used for Connection pool: batchHandler.BatchComplete += new BatchHandler.BatchHandlerDelegate(batchHandler_BatchComplete);
}
// If the NotifyOnEmptyBatch property is set to true, and the batch is empty,
// an "emty batch message" is created and added to the batch. This message can
// later be picked up by the pipeline components.
else if (fileEntries.Count == 0 && this._properties.NotifyOnEmptyBatch)
{
    Trace.WriteLine(string.Format("[SftpReceiverEndpoint] Sending notification on empty batch.", fileEntries.Count - 1));
    batchHandler = new BatchHandler(sftp, this._propertyNamespace, this._transportType, this._transportProxy, this._properties.DebugTrace, this._properties.UseLoadBalancing);
    batchHandler.CreateEmptyBatchMessage(this._properties.Uri);
    // Used for Connection pool: batchHandler.BatchComplete += new BatchHandler.BatchHandlerDelegate(batchHandler_BatchComplete);
}
else
{
    sftp.Disconnect();
    sftp.Dispose();
    sftp = null;
    // Used for Connection pool: SftpConnectionPool.GetHostByName(this._properties.SSHHost, this._properties.DebugTrace).ReleaseConnection(sftp);
    return false;
}

HTH

//Mikael

Jul 19, 2009 at 11:03 PM

Thank you again for the reply and thank you for the code fix and ofcourse for use of a terrific adapter. 

Don

Coordinator
Jul 20, 2009 at 8:30 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.