custom logic not working

Hi. I am working on custom backend logic. Actually i have to insert rows in a table when a user register to the application. But to keep it simple initially I just change the name of user after registration. I have deployed the custom logic but it didn’t working.
First I didn’t use Async then I received this email

This is a notification to inform you that a business logic code running in your application has been interrupted prematurely. The interruption was caused by the business logic taking longer than the plan limit.
The information about the limit can be found below.
Application name: StuNexus
Application ID: CF512434-CCA8-067C-FF92-D76481A44000
Version name: v1
Maximum allowed business logic runtime: 5 seconds
If you are already aware of this condition and are working on a solution, please ignore this email. Otherwise, it is important to make any adjustments to the business logic so it completes the execution within the allotted time or increase the limit by purchasing a function pack.

and if I use Async then it did not change the value.
here is my code for logic
Kindly help

package com.stunexus.events.user_service;
import com.backendless.servercode.ExecutionResult;
import com.backendless.servercode.RunnerContext;
import com.backendless.servercode.annotation.Async;
import java.util.HashMap;
 
public class GenericUserEventHandler extends com.backendless.servercode.extension.UserExtender
{
 @Async
 @Override
 public void afterRegister( RunnerContext context, HashMap userProperties, ExecutionResult<HashMap> result ) throws Exception {
 userProperties.put("name", "David Joey");
 result.getResult().put("name", "David Joey");
 }
}
 

Hi Mubtada,

Currently I can see only beforeRegister handler deployed in your application. Could you please also deploy the one you mention so that we could try to test it?

The problem is the deployed handler is not working. According to this line “userProperties.put(“name”, “David Joey”);” It should have change the name of user to “David Joey” but it is not working.

I have the same issue today. Approximately every second query to my custom handlers returns me “Custom business logic execution has been terminated because it did not complete in permitted time - 5 seconds”. Previously all works fine.

But the code you provided is for afterRegister event, and the event handler you have deployed is beforeRegister. If the deployed one (beforeRegister) is not working, please provide its source code, too.

Hi Alexandr,

Please create a dedicated topic and provide your app ID and an example of the call so that we could test it. Thanks in advance and sorry for the inconvenience!

I have deployed the afterRegister handler. plus I’m having the same problem ‘Alaxender’ has. I have also mentioned the email content in the problem description.

My application ID is: CF512434-CCA8-067C-FF92-D76481A44000

You can see that I have only afterRegistration handler

Yes, I can see it now.

I just tried the following curl request several times and it worked fine, could you please verify it too?

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}
span.s1 {font-variant-ligatures: no-common-ligatures}

curl -H application-id:CF512434-CCA8-067C-FF92-D76481A44000 -H secret-key:6B6FDEEC-0909-2FF2-FF89-7A51CEAD9E00 -H Content-Type:application/json -d '{"email":"test@backendless.com", "password":"qwe", "name":"TestBackendless"}' -X POST https://api.backendless.com/v1/users/register

It’s not working. I have deployed the above mentioned code but it did not change the user’s name to ‘David Joey’. I have attached a screenshot of my User Table plus i have mentioned the rows on which i have tested the logic,

The afterRegister operation only modifies the resulting response when the user is already registered, so in your data table you’ll have the initial name. Also, in your case, since user confirmation is required, you will not even see the result of afterRegister actions.

In order to modify the user’s name before the actual saving into the data service, you’ll need to use beforeRegister handler.

Its not working. Now I have 3 handler, 1 for beforeRegistration, 1 for afterRegistration and 1 custom business logic to insert rows into tables. I have deployed these handler but it is not working. Here is my code for handlers

package com.stunexus.events.custom_events; 
import com.backendless.Backendless; 
import com.backendless.servercode.RunnerContext; 
import com.backendless.servercode.annotation.Asset; 
import com.backendless.servercode.annotation.Async; 
import com.backendless.servercode.annotation.BackendlessEvent; 
import com.backendless.servercode.annotation.BackendlessGrantAccess; 
import com.backendless.servercode.annotation.BackendlessRejectAccess; 
 
import java.util.Collections; 
import java.util.HashMap; 
import java.util.Map; 
 
/** 
* UserskillEventHandler handles custom event "userskill". This is accomplished with the 
* BackendlessEvent( "userskill" ) annotation. The event can be raised by either 
* the client-side or the server-side code (in other event handlers or timers). 
* The name of the class is not significant, it can be changed, since the event 
* handler is associated with the event only through the annotation. 
*/ 
@BackendlessEvent( "userskill" ) 
public class UserskillEventHandler extends com.backendless.servercode.extension.CustomEventHandler 
{ 
 
 @Async 
 @Override 
 public Map handleEvent( RunnerContext context, Map eventArgs ) 
 { 
 
 HashMap contact = new HashMap(); 
 contact.put( "name", "test" ); 
 Map savedContact = Backendless.Persistence.of( "Organization" ).save( contact ); 
 
 return Collections.emptyMap(); 
 } 
 
}


package com.stunexus.events.user_service; 
 
import com.backendless.Backendless; 
import com.backendless.BackendlessCollection; 
import com.backendless.commons.util.SocialType; 
import com.backendless.persistence.BackendlessDataQuery; 
import com.backendless.property.UserProperty; 
import com.backendless.servercode.ExecutionResult; 
import com.backendless.servercode.RunnerContext; 
import com.backendless.servercode.annotation.Async; 
 
import java.util.HashMap; 
import java.util.Map; 
 
 
public class GenericUserEventHandler extends com.backendless.servercode.extension.UserExtender 
{ 
 
 @Async 
 @Override 
 public void beforeRegister( RunnerContext context, HashMap userProperties ) throws Exception 
 { 
 userProperties.put("name","David Joey"); 
 } 
 
 @Async 
 @Override 
 public void afterRegister( RunnerContext context, HashMap userProperties, ExecutionResult<HashMap> result ) throws Exception 
 { 
 Backendless.Events.dispatch( "userskill", null ); 
 // add your code here 
 } 
 
} 
 


Kindly help
here it is another thing that I have deployed these handlers without debugging, is that a problem?