Backendless Support
 
Cannot Reproduce

Event Handlers not working

Hi

I m trying to handle changes of value data table throught Rest API (PUT request) but Event Handler doesnt call any method like "beforeUpdate" , logs like System.out.println("beforeUpdate") and debugger breakpoints not calls also , just Waiting for events...

  1. @Asset("User")

    public class UserTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<User> {

    @Override

    public void beforeUpdate(RunnerContext context, User user) throws Exception {

    System.out.println("update ");

    }

Best Answer
photo

Seems to be like a caching issue, should be fine now. There is a probability that this problem may occur again, if so - please contact us here ASAP. For now I've scheduled an internal task to investigate and fix the problem (ticket Id: BKNDLSS-16628)

Anton

Leave a Comment

Comments (37)

photo
1

Hi, Alex.

What is your appId ?

photo
1

4D267860-480C-DA5A-FFAF-9D5D7F4D0F00

photo
photo
1

I see in your app only js handlers, and the code posted above is for java coderunner.

Howbeit, if you want to intercept operations with users (from system "Users" table), try use Category:Users when your are creating handlers.

https://screenshots.firefox.com/gnjOIysZQabblZQR/backendless-dev.local

photo
1

-> I see in your app only js handlers

Very strange

http://joxi.ru/v29OOeEcGoGXqr

and

http://joxi.ru/Q2Keedyh9x9MBr

photo
2

Ok, it's really very strange, cause i saw it like js.

Now i've seen your custom "User" table and try with it.

photo
photo
1

Please, try again, now it should work.

photo
2

I m trying to check it on debug mode throught REST API and I still dont see any logs nor debug events(

photo
photo
1

Hi Alex,

I was not able to reproduce the problem in my application. Do you mind if I try to create a beforeUpdate handler in your app and will make some tests there?

Anton

photo
1

yes ofc

photo
photo
1

Seems to be like a caching issue, should be fine now. There is a probability that this problem may occur again, if so - please contact us here ASAP. For now I've scheduled an internal task to investigate and fix the problem (ticket Id: BKNDLSS-16628)

Anton

photo
1

Event handler for User table doesnt fire any events again :-(

photo
1

I've tried to fix this problem manually. Please, try once again. Sorry for inconvenience.

The work on this issue is still in progress and expected to be finished on the next week.

photo
1

pls, notify me when this issue will be fixed

photo
1

Sure

photo
1

Hello, tell me please when will the problem be solved? When are you planning to start?

photo
1

We are working on this issue. The fix will be delivered on the next week

photo
1

Good afternoon!

What is the status of this issue?

That week, there no corrections like you wrote

We can not work normally for about a month now.

photo
1

Hi Vitalii,

We tried to release the fix 2 days ago, but unfortunately had to rollback due to a regression. Hopefully we'll have a fix on this week. Sorry for the delay.

photo
photo
1

Now I m get {"code":14021,"message":"Debugging utility is disconnected","errorData":{}} on PUT requests

photo
1

Debug session lasts for 2 hours, you need to redeploy your business logic.

Anton

photo
1

Hi Alex

Fixed, should be OK now. But you'll need to regenerate your servercode project. Sorry for delay, it took more than we expected

Regards,

Anton

photo
1

Hello .

I m trying to add some custom logic using event handler .

When I added event handler with beforeUpdate and afterUpdate override (just call 'super' (java), without any code) in debug mode it had begun creates every time new user entity with different objectId ((

without event handler all works fine

photo
1

Hi Alex,

Is it about your custom table 'User' or the system table 'Users'? If this is your custom 'User' table, please provide the java class declaration.

photo
1

  1. package com.voice_vk.events.persistence_service;
  2. import com.backendless.servercode.ExecutionResult;
  3. import com.backendless.servercode.RunnerContext;
  4. import com.backendless.servercode.annotation.Asset;
  5. import com.voice_vk.models.User;
  6. /**
  7. * UserTableEventHandler handles events only for the "User" table. This is accomplished
  8. * with the @Asset( "User" ) annotation.
  9. * The methods in the class correspond to the events selected in Backendless
  10. * Console.
  11. */
  12. @Asset("User")
  13. public class UserTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<User> {
  14. @Override
  15. public void beforeUpdate(RunnerContext context, User user) throws Exception {
  16. super.beforeUpdate(context, user);
  17. }
  18. @Override
  19. public void afterUpdate(RunnerContext context, User user, ExecutionResult<User> entity) throws Exception {
  20. super.afterUpdate(context, user, entity);
  21. }
  22. }

photo
1

User is POJO

photo
1

Still I'd like to see the source of the User class to check which properties are declared and how.

photo
2

  1. package com.voice_vk.models;

    import com.backendless.Backendless;

    public class User {

    private Double balanceAppLovin;

    private java.util.Date created;

    private String uid;

    private String ownerId;

    private java.util.Date date_created;

    private java.util.Date updated;

    private Double balanceNativeX;

    private Double balanceIronSource;

    private String objectId;

    private Double balanceOfferToro;

    private Double balanceKazoolink;

    private Double balanceAdColony;

    private Double balanceTapJoy;

    private Integer appLovinDailyValue;

    public Double getBalanceAppLovin() {

    return this.balanceAppLovin;

    }

    public java.util.Date getCreated() {

    return this.created;

    }

    public String getUid() {

    return this.uid;

    }

    public String getOwnerId() {

    return this.ownerId;

    }

    public java.util.Date getDate_created() {

    return this.date_created;

    }

    public java.util.Date getUpdated() {

    return this.updated;

    }

    public Double getBalanceNativeX() {

    return this.balanceNativeX;

    }

    public Double getBalanceIronSource() {

    return this.balanceIronSource;

    }

    public String getObjectId() {

    return this.objectId;

    }

    public Double getBalanceOfferToro() {

    return this.balanceOfferToro;

    }

    public Double getBalanceKazoolink() {

    return this.balanceKazoolink;

    }

    public Double getBalanceAdColony() {

    return this.balanceAdColony;

    }

    public Double getBalanceTapJoy() {

    return this.balanceTapJoy;

    }

    public void setBalanceAppLovin(Double balanceAppLovin) {

    this.balanceAppLovin = balanceAppLovin;

    }

    public void setCreated(java.util.Date created) {

    this.created = created;

    }

    public void setUid(String uid) {

    this.uid = uid;

    }

    public void setOwnerId(String ownerId) {

    this.ownerId = ownerId;

    }

    public void setDate_created(java.util.Date date_created) {

    this.date_created = date_created;

    }

    public void setUpdated(java.util.Date updated) {

    this.updated = updated;

    }

    public void setBalanceNativeX(Double balanceNativeX) {

    this.balanceNativeX = balanceNativeX;

    }

    public void setBalanceIronSource(Double balanceIronSource) {

    this.balanceIronSource = balanceIronSource;

    }

    public void setObjectId(String objectId) {

    this.objectId = objectId;

    }

    public void setBalanceOfferToro(Double balanceOfferToro) {

    this.balanceOfferToro = balanceOfferToro;

    }

    public void setBalanceKazoolink(Double balanceKazoolink) {

    this.balanceKazoolink = balanceKazoolink;

    }

    public void setBalanceAdColony(Double balanceAdColony) {

    this.balanceAdColony = balanceAdColony;

    }

    public void setBalanceTapJoy(Double balanceTapJoy) {

    this.balanceTapJoy = balanceTapJoy;

    }

    public User save() {

    return Backendless.Data.of(User.class).save(this);

    }

    public Long remove() {

    return Backendless.Data.of(User.class).remove(this);

    }

    public static User findById(String id) {

    return Backendless.Data.of(User.class).findById(id);

    }

    public static User findFirst() {

    return Backendless.Data.of(User.class).findFirst();

    }

    public static User findLast() {

    return Backendless.Data.of(User.class).findLast();

    }

    public Integer getAppLovinDailyValue() {

    return appLovinDailyValue;

    }

    public void setAppLovinDailyValue(Integer appLovinDailyValue) {

    this.appLovinDailyValue = appLovinDailyValue;

    }

    }

photo
1

Hi

You saw the previous message from Alex? Just the status of the topic has not changed and I decided to clarify)

photo
photo
1

Hi guys,

Unfortunately I can't reproduce the problem. Do you mind if I try this use-case on your environment? Your appId is: 4D267860-480C-DA5A-FFAF-9D5D7F4D0F00, right?

photo
1

Yes, this is our appID and we do not mind, try)

photo
photo
1

Hi again,

Still can't reproduce it) Added before and afterUpdate Java handlers for 'User' table (you can see them in drafts in your Business Logic tab), added code you've posted and system.out code to verify invocation in debug - and everything works like a charm, additional objects were not created. Added a screenshot of BL logic

Please try regenerating code for handlers and try again

Anton

photo
photo
1

Alex, how are you validating that new object has been created? Requests in steps 2 and 4 return more then 100+ objects (if you add additional parameter "&pagesize=100").

I've tried making an update, then checking count of objects in table 'User' - did not reproduce.

Then added a beforeCreate handler to 'User' table to catch object creation event and repeated the use-case - and there were no signs of object creation as a result of handling an update event in business logic.

Before and after an update I've compared two arrays of JSONs from responses and they were identical

photo
1

Request

  1. 04-06 13:24:40.850 27060-27119/com.mobile.account.free D/OkHttp: --> GET https://api.backendless.com/4D267860-480C-DA5A-FFAF-9D5D7F4D0F00/169D6A8C-623A-120E-FFB0-1E64E04ACC00/data/User?where%3Duid=%27b96d4890-8b23-4fd2-915d-66b095269dcdcom.mobile.account.free%27 http/1.1
  2. 04-06 13:24:40.851 27060-27119/com.mobile.account.free D/OkHttp: --> END GET

Response

  1. 04-06 13:24:42.302 27060-27119/com.mobile.account.free D/OkHttp: <-- 200 OK https://api.backendless.com/4D267860-480C-DA5A-FFAF-9D5D7F4D0F00/169D6A8C-623A-120E-FFB0-1E64E04ACC00/data/User?where=uid%3D%27b96d4890-8b23-4fd2-915d-66b095269dcdcom.mobile.account.free%27 (1451ms)
  2. Server: nginx
  3. Date: Fri, 06 Apr 2018 10:24:41 GMT
  4. Content-Type: application/json
  5. Content-Length: 409
  6. Connection: keep-alive
  7. Access-Control-Allow-Origin: *
  8. Access-Control-Allow-Headers: Origin, application-type, Content-Type, request, user-token, auth-key
  9. Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, PATCH
  10. Expires: Thu, 01 Jan 1970 00:00:01 GMT
  11. Cache-Control: no-cache
  12. Cache-Control: : no-store, no-cache, must-revalidate, private
  13. Pragma: : no-cache
  14. 04-06 13:24:42.304 27060-27119/com.mobile.account.free D/OkHttp: [{"balanceAppLovin":0.0,"appLovinDailyValue":0,"balanceKazoolink":0.0,"created":1523010215881,"date_created":null,"balanceNativeX":0.0,"ownerId":null,"balanceIronSource":0.0,"balanceAdColony":0.0,"uid":"b96d4890-8b23-4fd2-915d-66b095269dcdcom.mobile.account.free","balanceOfferToro":0.0,"balanceTapJoy":0.0,"updated":null,"objectId":"994429DA-5757-7092-FF16-0DCD5740F800","balanceAyet":0.0,"___class":"User"}]
  15. <-- END HTTP (409-byte body)

From mobile app it retuns only 1 user. Try to go over URL from response .

photo
photo
1

yes it returns one user. is it worng?

photo
1

now you can go over steps to reproduce the bug )

photo
photo
1

we can not reproduce the bug with your steps.

there is no any additional record when we update a record in the table which has buissiness logic