13.4 iAnywhere Solutions MobiLinkMobiLink is the synchronization engine in iAnywhere Solutions' SQL Anywhere Studio (v8.0, see Chapter 11, Section 11.7). It synchronizes iAnywhere Adaptive Server Anywhere and UltraLite mobile databases with enterprise databases, including Oracle, IBM DB2, Microsoft SQL, and Sybase Adaptive Server Enterprise. Important features of MobiLink are the following:Flexible synchronization logic through user-defined sync scripts.The synchronization script is written for and stored in the enterprise database, which allows developers to use SQL dialects that they are already familiar with.Multiple communication protocols are supported for synchronization streams. Those protocols include TCP/IP, HTTP, and direct serial line.Each synchronization operation is a transaction with guaranteed integrity.Adjustable parameters (such as cache size, maximum number of threads) for performance tuning.Strong security through user authentication and 128-bit encrypted synchronization data streams. 13.4.1 MobiLink via Standalone Native ClientsMobiLink can be manually invoked by native clients on devices. We go through the following steps to complete a synchronization cycle. Create a synchronization username and password through the Sybase Central administration panel.In the Sybase Central administration panel's MobiLink plug-in, select tables that are available for synchronization from backend databases.Write SQL scripts for each sync event. For example, an upload_insert event might trigger a simple SQL INSERT statement, while a download_cursor event might trigger an SQL SELECT statement. We can skip this step and use the default scripts if there is no custom synchronization logic.On the remote (mobile) database, create a publication containing tables to synchronize using the statement CREATE PUBLICATION.On the remote database, create a user and associate a publication with the user through a subscription. Related statements are CREATE SYNCHRONIZATION USER and CREATE SYNCHRONIZATION SUBSCRIPTION. The subscription also contains the synchronization server address and the data communication protocol (e.g., TCP/IP, HTTP, or serial link).Run the remote sync client. NoteThe concepts of publication and subscription in Sybase MobiLink is different from other synchronization engines.13.4.2 Access MobiLink ProgrammaticallyThe MobiLink synchronization client can be invoked as a command-line utility. But for autogenerated UltraLite databases, the MobiLink API is already built in. The following code snippet (Listing 13.5) demonstrates how to synchronize the entire clientside Java UltraLite database. Listing 13.5. Using MobiLink
If you have a homogeneous environment containing only iAnywhere databases, Sybase has another synchronization product called SQL Remote. SQL Remote supports message-based asynchronous operation and is therefore scalable. Interested readers should refer to iAnywhere documentation for that technology. |