Backendless Support

Custom event handler isn't triggered when dispatching an event with client-side API (debug)

There is a custom event which I try to dispatch via client-side API.

I use the version of Code Runner which went with the generated project for the custom event and IntelliJ IDE to debug it.

I have set breakpoints to check whether the event handler is triggered. When I dispatch the event from timer (i.e.directly), everything seems to be alright. But when I try to do it using client-side API (REST), I get "OK" response from server, but the event doesn't seem to be triggered ( as the breakpoint isn't hit ).

This is the code for event handler in Java ( generated via console ) :

  1. @BackendlessEvent( "Sync_event" )
  2. public class Sync_eventEventHandler extends com.backendless.servercode.extension.CustomEventHandler
  3. {
  4. @Async
  5. @Override
  6. public Map handleEvent( RunnerContext context, Map eventArgs )
  7. {
  8. System.out.println("got here");
  9. Map result = new HashMap();
  10. result.put("hello", "world");
  11. return result;
  12. }
  13. }

This is the request I send to dispatch Sync_event:

  1. curl -H application-id:<my-app-id>
  2. -H secret-key:<my-secret-key>
  3. -H application-type:REST
  4. -H Content-Type:application/json
  5. -X POST -d '{"hello":"world"}'
  6. -v

Am I missing something?

Thank you.

P.S. At first I tried dispatching the event using client-side API for iOS (an async method with block-based callbacks) but I kept receiving an empty response. So I've switched to REST API to make it easy to check whether the event handler is triggered at all.

Leave a Comment

Comments (2)



Could you try to remove @Async annotation, rebuild project and run in debug again?




Hi, Kate!

That worked!

Thank you