Hello
I am using backendless on Java (not Android) application locally to test before I move it to become become timer cloud code.
I am trying to do a deep save like
Backendless.Data.of( “TestInvPrdTable” ).deepSave( invHM, new AsyncCallback()
{
@Override
public void handleResponse( Map savedObject )
{
System.out.println( "Product object has been saved " + savedObject.get( “objectId” ) );
}
@Override
public void handleFault( BackendlessFault fault )
{
System.out.println( "Server reported an error " + fault.toString() );
}
} );
While the data is saved successfully, the asyncCallback is not being invoked. I dont see print out and even when I put breakpoint it does not hit it.
Am I missing something here?
Thank you
Are you running it in a standalone java program? If not, then how?
Yes it is standrard Java program
public static void main(String[] args) {
new Integrator().run();
}
public void run() {
Backendless.initApp(APPLICATION_ID, API_KEY);
try {
Map savedObject =
Backendless.Data.of("TestInvPrdTable").deepSave(invHM);
System.out.println("Product object has been saved " + savedObject.get("objectId"));
} catch (BackendlessException ex) {
System.out.println( "Server reported an error " + ex.toString() );
}
}
However I noticed something following some debuggings which is that actually asyncallback is getting invoked but the system.out is not prinitng. Probably because the main program finish this statement and terminates and then threads are cleaned before they are getting a chance to execute? I think only blocking methods should be used in case of java standalone program. Right?
Now when I make the code as TimeCode in the cloud, do I also just use blocking methods or will the async callback work?
Hello @Deress_Asghedom
Yes, you are right
You can also wait for execution, something like Thread.sleep( long millis )
.
Just use blocking methods.
Regards,
Vladimir