Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » MobiLink - Server Administration » MobiLink events » Synchronization events

nonblocking_download_ack connection event

When you use download acknowledgement, this script provides a place to record the information that a download has been applied successfully, or to trigger business logic that depends on the download being confirmed as applied.


In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, use the appropriate corresponding data type.

In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated. Use named parameters instead. You cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you are going to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.

Parameter name for SQL scripts Description Order (deprecated for SQL)
s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable


VARCHAR(128). The MobiLink user name.



TIMESTAMP. This is the last download time for the current synchronization.


s.script_version VARCHAR(128). Optional IN parameter to specify that the MobiLink server passes the script version string used for the current synchronization to this parameter. Question marks cannot be used to specify this parameter. Not applicable

This event lets you record the time when the download was successfully applied at the remote database.

This event is only called when using download acknowledgement. The download transaction is committed and the synchronization ends when the download is sent. This event is called when the synchronization client acknowledges a successful download. This event is called on a new connection, after the end_synchronization script of the original synchronization. The actions of this event are committed along with an update to the download time in the MobiLink system tables.

Due to the special nature of this script, any connection-level variables set during the synchronization are not available when this event is executed.

Note If the download is unsuccessful or if the network connection is dropped, there is no acknowledgement and this script is not invoked. If timely download acknowledgement is critical to your business needs, you should use the last_download parameter of the prepare_for_download script or the last_publication_download parameter of the begin_publication script as backups for your download acknowledgement processing.
SQL example

The following script adds a record to the table download_pubs_acked. The record contains the remote ID, the first authentication parameter, and the download timestamp.

INSERT INTO download_pubs_acked( rem_id, auth_parm, last_download )
   VALUES( {ml s.remote_id},  {ml a.1}, {ml s.last_download} )
Java example

The following call to a MobiLink system procedure registers a Java method called confirmDownload as the script for the nonblocking_download_ack event when synchronizing the script version ver1.

CALL ml_add_java_connection_script(
   'ExamplePackage.ExampleClass.confirmDownload' )

The following is the sample Java method confirmDownload. It calls a Java method to perform business logic based on the download being confirmed, up to the given timestamp, for the given user.

package ExamplePackage;
import java.sql.*;
public class ExampleClass
    DBConnectionContext _cc;
    public ExampleClass( DBConnectionContext cc ) 
	_cc = cc;

    public void confirmDownload( String user,
				   Timestamp ts ) 
	throws SQLException
	Connection conn = _cc.getConnection();
	PreparedStatement stmt = conn.prepareStatement( 
		"INSERT INTO download_pubs_acked( rem_id, last_download ) " +
		"VALUES( ?,  ? )" );
	stmt.setString( 1, _cc.getRemoteID() );
	stmt.setTimestamp( 2, ts );
.NET example

The following call to a MobiLink system procedure registers a .NET method called ConfirmDownload as the script for the nonblocking_download_ack connection event when synchronizing the script version ver1.

CALL ml_add_dnet_connection_script( 

The following is the sample .NET method ConfirmDownload. It calls a .NET method to perform business logic based on the download being confirmed, up to the given timestamp, for the given user.

using System;
using Sap.MobiLink.Script;
namespace TestScripts
    public class Test
	DBConnectionContext _cc;

	public Test( DBConnectionContext cc )
	    _cc = cc;
	public void ConfirmDownload( string user,
				     DateTime dt )
	    DBConnection conn = _cc.GetConnection();

	    DBCommand cmd = conn.CreateCommand();
	    cmd.CommandText = 
		    "INSERT INTO download_pubs_acked( rem_id, last_download ) " +
		    "VALUES( ?,  ? )";
	    cmd.Parameters[0] = _cc.GetRemoteID();
	    cmd.Parameters[1] = dt;