cancel
Showing results for 
Search instead for 
Did you mean: 

SyncManager.getInstance().synchronizeWithBackend();

Former Member
0 Kudos

Does anyone has some experience with the following function:

SyncManager.getInstance().synchronizeWithBackend();

The api says that it will Handles the complete synchronization for the current user. But I can't believe this is true, because the synchronization time of this sync call is much shorter then I use the sync button of MI. (source: https://media.sdn.sap.com/javadocs/NW04/SPS15/me/com/sap/ip/me/api/sync/SyncManager.html)

Can anyone explain to me why the sync with this function is shorter? Or does anyone has more documentation then I have.

Thank you in advance.

Chris Bogers

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Karthik,

I'm still a little bit confused, you are telling me that SyncManager.getInstance().synchronizeWithBackend(); works as a normal sync, but Rahul tells me that only the application data gets downloaded.

So what is the real answer?:

1. Complete sync.

2. Only data sync (upload / download).

3. Maybe there is documenatation over this function / method that explains what is happening and what will NOT happen.

Thank you.

Former Member
0 Kudos

Hi Chris,

Maybe I was a bit misleading in my last post, What I meant was that both synchronizeWithBackend() and normal sync you dont have to catch any errors. In that way they are similar.

The ONLY difference is that deployment of addons/patches are not done in synchronizeWithBackend(), in every other aspect it is the same. So when synchronizeWithBackend() is performed all data for the current user is transferred INCLUDING the MI framework data. You can get some more information about this is the API documentation.

Hope this clears your doubts.

Regards,

Karthik

Answers (10)

Answers (10)

Former Member
0 Kudos

Hi All,

When you set the Synchroom setting in the ALMConfig.properties file, does this function SyncManager.getInstance().synchronizeWitehBackend() use this setting or is it always A-SYNC ?

Thank you in advance.

Chris

Former Member
0 Kudos

hi chris,

please refer to https://forums.sdn.sap.com/click.jspa?searchID=623836&messageID=2879088

on how to change the synchronization method thru MAM's properties files.

regards

jo

Former Member
0 Kudos

Hi Chris,

SyncManager.getInstance().synchronizeWitehBackend() will also use the settings in the ALMConfig.properties files. That is because MAM registers the observers which read the sync property from the property file and changes the behavior of the syncBos. When the method SyncManager.getInstance().synchronizeWitehBackend() is called these observers get notified.

Best Regards,

Karthik

Former Member
0 Kudos

Hi All,

I have still another question, when I call this function with a LAN connection everything works just fine, BUT when I use a GPRS connection he only sends the created TimeConfirmation that I just create before this function call.

Does anybody has the same experience with this?

Thank you.

Chris

Former Member
0 Kudos

Hi Karthik,

And whem i'm using ASYNC?

Chris

Former Member
0 Kudos

Hi Chris,

Both the changed data and the request for new data is done in the same method call.

For Synchronous sync the reply to the changed data and the new data is sent back in the same sync.

For Asynchronous sync the reply to the changed data and the new data is sent back in the next sync. (ie you have to call the method again)

Best Regards,

Karthik

Former Member
0 Kudos

hi chris,

when in async mode, the synchronization process is still the same as the sync

mode only that it will not wait for the response to the last uploaded message.

during sync, the data update from the client are sent first, then the delta data

download request is sent. there'll be sometime that your updates will be completely

processed by the middleware before the download request is sent by the client.

thus the response is retrieved in just one sync cycle. however, if the response to

your data updates are not yet available when the delta data request was sent, you

won't be getting it in one sync cycle; and might require you to sync twice or more

than than depending on the middleware's status.

hope this helps.

regards

jo

Former Member
0 Kudos

Hi,

Still I have another question. When I create a time confirmation on the client, and I call the synchronize function, he only send the time confirmation and he doesn't do a request for new data.

So the function only sends data when he needs to send data, if no data available to send, then he does a request for new data.

So I have to call the function 2 times?

Chris

Former Member
0 Kudos

Hi Chris,

The synchronizeWithBackend() method will find send the changed data and then request for new data. This is done in one call. You dont have to call the method twice.

Best Regards,

Karthik

Former Member
0 Kudos

So for i tried the following:

try {

SyncManager.getInstance().synchronizeWithBackend();

} catch (HttpConnectionException h) {

System.out.println(h.getMessage());

}

But the compiler wants to remove the catch clause, I think this is not working, because the function doesn't throw any exceptions.

Is there a function withing the SAP api to check the connection?

Thank you.

Chris Bogers

Former Member
0 Kudos

Hi Chris.

I am sorry it was too long ago I used this method.

You can get sync messages from the SyncLog:


SyncLog syncLog;
SyncManager.getInstance().synchronizeWithBackend();
syncLog = SyncLog.getInstance();
        if (!syncLog.isReady()) {
            String[] errorMsgs = syncLog.getFailureMessages();
            for (int i = 0; i < errorMsgs.length; i++) {
                Log.log(Log.DEBUG_LEVEL, "[MEGateway.synchronize] msg {0}",
                        errorMsgs<i>);
                if (errorMsgs<i>
                        .equals(SyncException.TRANSPORT_LAYER_HTTP_SYNC_EXCEPTION)) {
                    Log.log(Log.DEBUG_LEVEL, "[MEGateway.synchronize]msg {0}",
                            errorMsgs<i>);
                    throw new HttpConnectionException(
                            "delivery.upload.errormsg.noconnection");
                }
            }
            throw new SyncException("sychronization failed");
        }

This way you can get the messages from the synchronisation.

Hope this helps.

Cheers,

Sascha

Message was edited by:

Sascha Dingeldey

Former Member
0 Kudos

I have another question about this function. I want to know if the connection was successfully or not?

Does anybody knows if this is possible?

Thank you in advance.

Chris Bogers

Former Member
0 Kudos

Hi Chris.

AFAIK you can say that the connection was successful if no Exception is thrown.

Cheers,

Sascha

Former Member
0 Kudos

But when I uses this function, it is not required to catch any exceptions, in which api can I found the exceptions, for example if connection is down and server is not know?

Thank you.

Chris

Former Member
0 Kudos

hello chris,

to check for connectivity please refer to this thread.

https://forums.sdn.sap.com/click.jspa?searchID=301896&messageID=2742583

regards

jo

Former Member
0 Kudos

Hi Karthik,

Yes that is a very clear answer, thank you very much for you help.

Chris Bogers

Former Member
0 Kudos

hello chris,

for the sake of completeness...

other than containers for data upload and donwload requests for the user/s, MI client

also creates requests to query not only for available addon/applications but also for

submission of client's profile and exchange of messages for the enabled agents;

like for example settings of additional parameters for the mobileengine.config, trace

enablement and some other administrative settings that are set by the administrator

from the middleware. so if you would only invoke the synchronizeWithBackend method

it will only sync the data for your user's applications.

hope this helps.

regards

jo

Former Member
0 Kudos

So to get everything clear, with SyncManager.getInstance().synchronizeWithBackend(); you have a complete DATA synchronization all other administrative (patches, etc.) will not be synced.

When I call this function, are there any errors I can catch? Or when I call this function does it wait till the sync is completed?

Thank you all in advance.

Former Member
0 Kudos

Hi Chris,

This would work exactly like a normal sync, so you dont have to catch any errors. If you have written any Observers( SyncReply or MessageReply) they would be called otherwise the method would wait till the sync is completed.

Let me know if you have any further queries.

Regards,

Karthik

Message was edited by:

Karthik V Setty

Former Member
0 Kudos

Hi Chris,

I am not sure but my understandig is that when u click the 'Sync' button then all the application data (data pertaining to the application on the client device) and the MI framework related data gets downloaded on to the client. Incase of SyncManager.getInstance().synchronizeWithBackend(); only the application data gets downloaded.

Regards,

Rahul

Former Member
0 Kudos

hello chris,

the sync button on the MI main page, doesn't invoke the

<b>SyncManager.getInstance().synchronizeWithBackend()</b>

method directly. rather it calls notifyR3 method which calls

this method in the process. notifyR3 method also tries to synchronize

other data for the agents and administration stuffs. that's why it

takes more time...

regards

jo

Former Member
0 Kudos

Hi Chris,

Another important point to note is that SyncManager.getInstance().synchronizeWithBackend() does not handle deployment, so if there are any new addons or patches waiting to be deployed this will not be done by this method. They will only be deployed when you do a sync from the MI homepage. This is one of the reasons for the difference in time.

Regards,

Karthik