cancel
Showing results for 
Search instead for 
Did you mean: 

SMP 3.0 MBO Data not Synchronization

Former Member
0 Kudos

HI Team

I Have created MBO with Oracle Database PL/SQL Function as Datasource. I can able to register the devices. After synchronization no new data available in local database. During MBO  Creation In MBO Tool kit i get data in Preview.

My Code:

public class MainActivity extends Activity {

  private static final String HOST = "IP";

  // private static final int PORT = 5001;

  private static final String USERNAME = "admin";

  private static final String PASSWORD = "admin";

  private static volatile boolean initializationDone = false;

  private static int TIMEOUT = 600;

  @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  initializeApplication();

  }

  private void initializeApplication()

    {      

        final ProgressDialog dialog = new ProgressDialog(this);

        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

        dialog.setTitle("on boarding ...");

        dialog.setMessage("Please wait while download initial data...");

        dialog.setIndeterminate(false);

        dialog.setProgress(100);

        dialog.setCancelable(true);

        dialog.show();

        new Thread()

        {

            @Override

            public void run()

            {

                try

                {

                    int count = 0;

                    while (!initializationDone)

                    {

                        dialog.setProgress(++count);

                        Thread.sleep(500);

                        if (count == 100)

                        {

                            count = 0;

                        }

                    }

                    dialog.cancel();

                }

                catch (Exception e)

                {

                    dialog.cancel();

                }

            }

        }.start();

        NWCversion2DB.registerCallbackHandler(new CustomerDBCallback());

       

        Application app = Application.getInstance();

        app.setApplicationIdentifier("NWCversion2");

        app.setApplicationContext(MainActivity.this);

      

        new Thread(new Runnable()

        {

            @Override

            public void run()

            {

                try

                {

                    Application app = Application.getInstance();

                   // ApplicationCallback appCallback = new MyApplicationCallback();

                  //  app.setApplicationCallback(appCallback);

                   

                    //NWCversion2DB.registerCallbackHandler(new CustomerDBCallback());

                    NWCversion2DB.setApplication(app);

                    NWCversion2DB.getSynchronizationProfile().setServerName(HOST); // Convenience only

                    ConnectionProperties connProps = app.getConnectionProperties();

                    LoginCredentials loginCredentials = new LoginCredentials(USERNAME, PASSWORD);

                    connProps.setLoginCredentials(loginCredentials);

                    connProps.setServerName(HOST);

                    connProps.setPortNumber(5001);

                   

                    Log.i("SMP101","Starting Application Registration");

                    if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED)

                    {

                    try {

                    app.registerApplication(TIMEOUT);

                    }

                    catch (Exception e)

                    {

                    Log.e("SMP101","Cannot register " + e.getMessage());

                    }

                       

                    }

                    else

                    {

                        app.startConnection(TIMEOUT);

                    }

                    Log.i("SMP101","Application REGISTERED");

                    if (!NWCversion2DB.isSynchronized("default"))

                    {

                  

                    if(!NWCversion2DB.databaseExists())

                    {

                    NWCversion2DB.createDatabase();

                    }

                  

                    Log.i("SMP101","Starting Initial Sync");

                  

                    ConnectionProfile cp =                         NWCversion2DB.getSynchronizationProfile();

                    cp.setServerName(HOST);

                    cp.setPortNumber(2480);

                    NWCversion2DB.disableChangeLog();

                    NWCversion2DB.synchronize(); // Initial Synchronize

                     

                     

                        LogAuthSubscription sp = new LogAuthSubscription();

            sp.setSp_userName("User1");

            sp.setSp_password("1234567");

            //LoginAuthentication.addSubscription(sp);

                        NWCversion2DB.synchronize("SG_LogAuth");

                        //NWCversion2DB.synchronize();

                       // NWCversion1DB.synchronize("SG_LoginAuthentication");

                       

                        //String a=lS.getRTRN_STATUS()+"  By Single";

                       

                    //Log.v("By Single", ""+a);

                    //Log.v("NWC List", ""+s1.getRTRN_STATUS()+" By List");

                       

                      

                       

                        //Log.i("SMP101",a);

                    }

                    NWCversion2DB.enableChangeLog();

                }

                catch (Exception e)

                {

                    e.printStackTrace();

                }

                finally

               

                {

                    initializationDone = true;

                }

                MainActivity.this.runOnUiThread(new Runnable()

                {

                    @Override

                    public void run()

                    {

                       

                    }

                });

            }

        }).start();

    }

  private class CustomerDBCallback extends DefaultCallbackHandler

    {

        @Override

        public int onSynchronize(GenericList<SynchronizationGroup> groups, SynchronizationContext context)

        {

        Log.i("SMP101","OnSynchronize() called with STATUS " + context.getStatus());

            if (context.getStatus() == SynchronizationStatus.ERROR)

            {

            Log.e("SMP101","ERROR " +

                   "[Exception message = " + context.getException().getMessage() +

                   "\n" + context.getException().getStackTrace());

            }       

      

            if (context.getStatus() == SynchronizationStatus.STARTING)

            {

                MainActivity.this.runOnUiThread(new Runnable()

                {

                    @Override

                    public void run()

                    {

                        //Toast.makeText(MainActivity.this, "Synchronizing ... ", Toast.LENGTH_SHORT);

                  

                    System.out.println("Synchronizing");

                  

                  

                  

                    }

                });

            }

            else if (context.getStatus() == SynchronizationStatus.FINISHING || context.getStatus() == SynchronizationStatus.ASYNC_REPLAY_UPLOADED)

            {

                MainActivity.this.runOnUiThread(new Runnable()

                {

                    @Override

                    public void run()

                    {

                        Toast.makeText(MainActivity.this, "Synchronize done", Toast.LENGTH_SHORT);

                    System.out.println("Finished");

                  

                  

                    LogAuth log=new LogAuth();

                  

                    System.out.println("NWCLog"+log.getRTRN_STATUS());

                  

                    GenericList<LogAuth> s = LogAuth.findAll();

                        

                         for (LogAuth s1 : s) {

                        

                          Log.v("NWC List", ""+s1.getRTRN_STATUS()+" By List");

                  }

                        

                    }

                });

                /*if (SMP101SampleActivity.this.adapter != null)

                {

                    SMP101SampleActivity.this.adapter.refreshUI(false);

                }*/

            }

            return SynchronizationAction.CONTINUE;

        }

    }

  }

Accepted Solutions (0)

Answers (2)

Answers (2)

midhun_vp
Active Contributor
0 Kudos

Have you resolved the issue ?

midhun_vp
Active Contributor
0 Kudos

What is the cache group you are using ? If it is on demand cache group check the option "partition by requester and device ID" in the properties of cache group created. If there is any load parameter in the MBO map it with PK with "partition by requester and device ID" checked or map it with sync parameter.

You can check whether CDB is updated by following this blog,

The issue would be with the cache group you selected.

Midhun VP