Skip to content

Delayed Delivery

Publishers can specify the time when the message should be processed and delivered to subscribers. This can be done in addition to all other publishing options (basic publish, with headers. Scheduled messages can be canceled at any time using the message cancellation API.

// do not forget to call Backendless.initApp in the app initialization logic

DeliveryOptions deliveryOptions = new DeliveryOptions();
Date publishDate = new Date( System.currentTimeMillis() + 20000 ); // add 20 seconds
deliveryOptions.setPublishAt( publishDate );

Backendless.Messaging.publish(
        "This message was scheduled 20 sec ago",
        null,
        deliveryOptions, new AsyncCallback<MessageStatus>()
        {
          @Override
          public void handleResponse( MessageStatus response )
          {
             Log.i( "MYAPP", "Message has been scheduled" );
          }

          @Override
          public void handleFault( BackendlessFault fault )
          {
             Log.e( "MYAPP", "Server reported an error - " + fault );
          }
        } );