sp_hook_dbmlsync_ml_connect_failed

Use this stored procedure to retry failed attempts to connect to the MobiLink server using a different communication type or address.

Rows in #hook_dict table

Name

Value

Description

publication_n (in)

publication

The publications being synchronized, where n is an integer. There is one publication_n entry for each publication being uploaded. The numbering of n starts at zero.

MobiLink user (in)

MobiLink user name

The MobiLink user for which you are synchronizing.

script version (in)

script version name

The MobiLink script version to be used for the synchronization.

connection address (in|out) connection address When the hook is invoked, this is the address used in the most recent failed communication attempt. You can set this value to a new connection address that you want to try. If retry is set to true, this value is used for the next communication attempt. For a list of protocol options, see MobiLink client network protocol option summary.
connection type (in|out) network protocol When the hook is invoked, this is the network protocol (such as TCPIP) that was used in the most recent failed communication attempt. You can set this value to a new network protocol that you want to try. If retry is set to true, this value is used for the next communication attempt. For a list of network protocols, see CommunicationType (ctp) extended option.
user data (in|out) user-defined data State information to be used if the next connection attempt fails. For example, you might find it useful to store the number of retries that have occurred. The default is an empty string.
allow remote ahead (in|out) true | false This is true only if dbmlsync was started with the -ra option. You can use this row to read or change the -ra option for the current synchronization only. See -r option.
allow remote behind (in|out) true | false This is true only if dbmlsync was started with the -rb option. You can use this row to read or change the -rb option for the current synchronization only. See -r option.
retry (in|out) true | false Set this value to true if you want to retry a failed connection attempt. The default is FALSE.
Remarks

If a procedure of this name exists, it is called if dbmlsync fails to connect to the MobiLink server.

This hook only applies to connection attempts to the MobiLink server, not the database.

When a progress offset mismatch occurs, dbmlsync disconnects from the MobiLink server and reconnects later. In this kind of reconnection, this hook is not called, and failure to reconnect causes the synchronization to fail.

Actions of this procedure are committed immediately after execution.

Examples

This example uses the sp_hook_dbmlsync_ml_connect_failed hook to retry the connection up to five times.

CREATE PROCEDURE sp_hook_dbmlsync_ml_connect_failed ()
BEGIN
    DECLARE idx integer;
      
    SELECT value
      INTO buf
      FROM #hook_dict
      WHERE name = 'user data';
       
  IF idx <= 5 THEN
        UPDATE #hook_dict 
        SET value = idx 
        WHERE name = 'user data'; 
       
        UPDATE #hook_dict 
        SET value = 'TRUE'
        WHERE name = 'retry'; 
  END IF;
END;

The next example uses a table containing connection information. When an attempt to connect fails, the hook tries the next server in the list.

CREATE TABLE conn_list (
    label   INTEGER PRIMARY KEY,
    addr  VARCHAR( 128 ),
    type  VARCHAR( 64 )
);
INSERT INTO conn_list
 VALUES ( 1, 'host=server1;port=91', 'tcpip' );
INSERT INTO conn_list
 VALUES ( 2, 'host=server2;port=92', 'http' );
INSERT INTO conn_list
 VALUES ( 3, 'host=server3;port=93', 'tcpip' );
COMMIT;

CREATE PROCEDURE sp_hook_dbmlsync_ml_connect_failed ()
BEGIN
 DECLARE idx INTEGER;
 DECLARE cnt INTEGER;

 SELECT value
  INTO idx
  FROM #hook_dict
  WHERE name = 'user data';
   
 SELECT COUNT( label ) INTO cnt FROM conn_list;
        
 IF idx <= cnt THEN
   UPDATE #hook_dict 
       SET value = ( SELECT addr FROM conn_list WHERE label = idx )
       WHERE name = 'connection address'; 
            UPDATE #hook_dict 
    SET value = (SELECT type FROM conn_list WHERE label=idx)
    WHERE name = 'connection type'; 
      
   UPDATE #hook_dict 
    SET value = idx
        WHERE name = 'user data'; 
       
       UPDATE #hook_dict 
        SET value = 'TRUE'
        WHERE name = 'retry';
 END IF;
END;