accessing a Backendless Table from within custom afterPublish event handler

Hey All,

As I am unable to reopen my previous Question, which I believe still remains unanswered. I am starting a brand new topic.

To refer to the old thread
http://support.backendless.com/t/backendless-messagingservice-push-notification-persistenceservice

Currently my team is having problems accessing PersistenceService from within the MessagingService.

Here’s what we are trying to achieve in a nutshell.

  1. We send a push notification via iOS Client. The responsible method here is
-(void)publish:(NSString
 *)channelName message:(id)message publishOptions:(PublishOptions 
*)publishOptions deliveryOptions:(DeliveryOptions *)deliveryOptions 
response:(void(^)(MessageStatus *))responseBlock error:(void(^)(Fault 
*))errorBlock;

Everything is perfect till now. Push Notifications are received in Both iOS and Android
Devices as expected.

We have even implemented a custom Messaging Service Handler at our server end and have successfully deployed it. We have
updated the afterPublish event handler.

 @Override
  public void afterPublish(
 RunnerContext context, Object message, PublishOptions publishOptions, 
DeliveryOptions deliveryOptions, ExecutionResult <MessageStatus> 
result ) throws Exception
  {
    // add your custom logic here
  }

Now
suppose we have a table, say PushMessageStatusTable in Backendless. As
soon as the afterPublish event handler is called/executed. We would like
to create a new record in the MessageStatusTable.

The problem is, we are having difficulties accessing PushMessageStatusTable from afterPublish Event Handler.

Is this possible at all??

Not to sound rude, but am I banging my head in the wrong place?

Maybe its easier to call Publish method from afterCreate Event Handler?

A lil help please. Thanks for reading through.

Hi!

“…The problem is, we are having difficulties accessing PushMessageStatusTable from afterPublish Event Handler.”
it is possible.
Please describe your difficulties.

Hi Kate,

Thank you for responding.

The problem we were facing was, when we created a custom Messaging Service Handler. We just couldn’t find a way for the Backendless Table to appear under roles.model (something like that folder in IntelliJ). Now this was something, we noticed happens by default when creating a Data Service Handler. Even adding the Backendless Table context directly to the downloading code dint work.

So this is what we did. We made a Data Service Handler first, passing the Backendless Table, that we want to access, as context. Doing this made the table appear in the role.model section. This code was then downloaded. Necessary changes were made in the afterPublish event handler of custom Messaging Service Handler. I was even able to get Advanced Object Retrieval (read whereClause) implemented on the table (Haven’t tested this yet though).

To cut the story short. You’re right it is possible and we have quite achieved it as well. Just wishing this hackaround is clean and wont mess with any other business logics.

One question though. Like I mentioned we created a dummy Data Service Handler, the main purpose for it was to make the Backendless Table accessible. Given that we don’t need it and wont be using it. Should we go ahead and delete it? or should we just let it be as it is. Keeping in mind, we can only have 5 Business Logics before we upgarde to the unlimited business logic plan, I would be more inclined towards deleting what we dont need. What do you suggest?

Updated!!

Hi.
Your workaround is correct.
After you download generated code (where in Bootstrap situated necessary mapping), you can quietly remove unnecessary handlers.

Thanks Oleg